[1/4] oledb32: DataConvert Support NULL variant in, DBTYPE_VARIANT->DBTYPE_WSTR (try 2)
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Sat May 25 18:19:15 CDT 2013
Hi,
Corrected crash in tests.
Changelog:
oledb32: DataConvert Support NULL variant in
DBTYPE_VARIANT->DBTYPE_WSTR
Best Regards
Alistair Leslie-Hughes
-------------- next part --------------
>From 5ceee6ab3b4eaca3009ca9a23d43beaddcba6ec7 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Fri, 24 May 2013 12:23:18 +1000
Subject: [PATCH] DataConvert Support NULL variant in
DBTYPE_VARIANT->DBTYPE_WSTR
To: wine-patches <wine-patches at winehq.org>
---
dlls/oledb32/convert.c | 3 ++-
dlls/oledb32/tests/convert.c | 19 +++++++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/dlls/oledb32/convert.c b/dlls/oledb32/convert.c
index 0961464..94ba4ce 100644
--- a/dlls/oledb32/convert.c
+++ b/dlls/oledb32/convert.c
@@ -787,7 +787,8 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
hr = IDataConvert_DataConvert(iface, src_type, DBTYPE_BSTR, src_len, &bstr_len,
src, &b, sizeof(BSTR), src_status, dst_status,
precision, scale, flags);
- if(hr != S_OK) return hr;
+ if(hr != S_OK || *dst_status == DBSTATUS_S_ISNULL)
+ return hr;
bstr_len = SysStringLen(b);
*dst_len = bstr_len * sizeof(WCHAR); /* Doesn't include size for '\0' */
*dst_status = DBSTATUS_S_OK;
diff --git a/dlls/oledb32/tests/convert.c b/dlls/oledb32/tests/convert.c
index fd69fed..88dc1d3 100644
--- a/dlls/oledb32/tests/convert.c
+++ b/dlls/oledb32/tests/convert.c
@@ -1017,6 +1017,7 @@ static void test_converttowstr(void)
static const WCHAR hexunpacked_w[] = {'5','7','0','0','6','9','0','0','6','E','0','0','6','5','0','0','0','0','0','0', 0 };
static const WCHAR hexpacked_w[] = {'W','i','n','e', 0 };
BSTR b;
+ VARIANT v;
memset(dst, 0xcc, sizeof(dst));
dst_len = 0x1234;
@@ -1470,6 +1471,24 @@ static void test_converttowstr(void)
ok(dst_len == 0, "got %ld\n", dst_len);
ok(dst[0] == 0, "not null terminated\n");
ok(dst[1] == 0xcccc, "clobbered buffer\n");
+
+ b = SysAllocStringLen(NULL, 0);
+ V_VT(&v) = VT_BSTR;
+ V_BSTR(&v) = b;
+ hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_WSTR, 0, &dst_len, &v, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
+ ok(hr == S_OK, "got %08x\n", hr);
+ ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status);
+ ok(dst_len == 0, "got %ld\n", dst_len);
+ ok(dst != NULL, "got %p\n", dst);
+ ok(dst != b, "got %p src %p\n", dst, b);
+ ok(!lstrcmpW(b, dst), "got %s\n", wine_dbgstr_w(dst));
+ VariantClear(&v);
+
+ V_VT(&v) = VT_NULL;
+ hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_WSTR, 0, &dst_len, &v, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
+ ok(hr == S_OK, "got %08x\n", hr);
+ ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
+ ok(dst_len == 0, "got %ld\n", dst_len);
}
static void test_converttostr(void)
--
1.8.1.2
More information about the wine-patches
mailing list