[2/5] oledb32: DataConvert Support NULL variant

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Fri May 24 03:04:43 CDT 2013


Hi,


Changelog:
      oledb32:


Best Regards
   Alistair Leslie-Hughes

-------------- next part --------------
>From aaf7aad2a9193479b9d736c7997ac872ffd36f2f 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] DataConver 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 | 24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/dlls/oledb32/convert.c b/dlls/oledb32/convert.c
index 64b7c8a..24dbe1a 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 dcc20a1..4f98413 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,29 @@ 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));
+    SysFreeString(dst);
+    SysFreeString(b);
+
+    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);
+    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));
+    SysFreeString(dst);
 }
 
 static void test_converttostr(void)
-- 
1.8.1.2




More information about the wine-patches mailing list