Alistair Leslie-Hughes : oledb32: DataConvert Support NULL variant in, DBTYPE_VARIANT->DBTYPE_WSTR.

Alexandre Julliard julliard at winehq.org
Mon May 27 13:46:54 CDT 2013


Module: wine
Branch: master
Commit: a1baa22d470cb6fcf1ce8e803ff9854e1b6dd926
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a1baa22d470cb6fcf1ce8e803ff9854e1b6dd926

Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date:   Fri May 24 12:23:18 2013 +1000

oledb32: DataConvert Support NULL variant in, DBTYPE_VARIANT->DBTYPE_WSTR.

---

 dlls/oledb32/convert.c       |    3 ++-
 dlls/oledb32/tests/convert.c |   19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/dlls/oledb32/convert.c b/dlls/oledb32/convert.c
index a2fd0cb..a33f933 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)




More information about the wine-cvs mailing list