Nikolay Sivov : msxml3: Respect string length returned from ISAXAttributes.

Alexandre Julliard julliard at winehq.org
Mon Aug 29 11:28:32 CDT 2011


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Sat Aug 27 15:01:57 2011 +0400

msxml3: Respect string length returned from ISAXAttributes.

---

 dlls/msxml3/mxwriter.c        |    7 ++++---
 dlls/msxml3/tests/saxreader.c |   12 ++++++------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/dlls/msxml3/mxwriter.c b/dlls/msxml3/mxwriter.c
index 31b8505..bf2411e 100644
--- a/dlls/msxml3/mxwriter.c
+++ b/dlls/msxml3/mxwriter.c
@@ -782,7 +782,7 @@ static HRESULT WINAPI mxwriter_saxcontent_startElement(
         for (i = 0; i < length; i++)
         {
             const WCHAR *str;
-            INT len;
+            INT len = 0;
 
             hr = ISAXAttributes_getQName(attr, i, &str, &len);
             if (FAILED(hr)) return hr;
@@ -790,16 +790,17 @@ static HRESULT WINAPI mxwriter_saxcontent_startElement(
             /* space separator in front of every attribute */
             xmlOutputBufferWriteString(This->buffer, " ");
 
-            s = xmlchar_from_wchar(str);
+            s = xmlchar_from_wcharn(str, len);
             xmlOutputBufferWriteString(This->buffer, (char*)s);
             heap_free(s);
 
             xmlOutputBufferWriteString(This->buffer, "=\"");
 
+            len = 0;
             hr = ISAXAttributes_getValue(attr, i, &str, &len);
             if (FAILED(hr)) return hr;
 
-            s = xmlchar_from_wchar(str);
+            s = xmlchar_from_wcharn(str, len);
             xmlOutputBufferWriteString(This->buffer, (char*)s);
             heap_free(s);
 
diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c
index 7419fe2..99a08c2 100644
--- a/dlls/msxml3/tests/saxreader.c
+++ b/dlls/msxml3/tests/saxreader.c
@@ -567,13 +567,13 @@ static HRESULT WINAPI isaxattributes_getQName(
     const WCHAR **pQName,
     int *pQNameLength)
 {
-    static const WCHAR attr1W[] = {'a',':','a','t','t','r','1',0};
-    static const WCHAR attr2W[] = {'a','t','t','r','2',0};
+    static const WCHAR attr1W[] = {'a',':','a','t','t','r','1','j','u','n','k',0};
+    static const WCHAR attr2W[] = {'a','t','t','r','2','j','u','n','k',0};
 
     ok(nIndex == 0 || nIndex == 1, "invalid index received %d\n", nIndex);
 
     *pQName = (nIndex == 0) ? attr1W : attr2W;
-    *pQNameLength = lstrlenW(*pQName);
+    *pQNameLength = (nIndex == 0) ? 7 : 5;
 
     return S_OK;
 }
@@ -654,13 +654,13 @@ static HRESULT WINAPI isaxattributes_getValue(
     const WCHAR ** pValue,
     int * nValue)
 {
-    static const WCHAR attrval1W[] = {'a','1',0};
-    static const WCHAR attrval2W[] = {'a','2',0};
+    static const WCHAR attrval1W[] = {'a','1','j','u','n','k',0};
+    static const WCHAR attrval2W[] = {'a','2','j','u','n','k',0};
 
     ok(nIndex == 0 || nIndex == 1, "invalid index received %d\n", nIndex);
 
     *pValue = (nIndex == 0) ? attrval1W : attrval2W;
-    *nValue = lstrlenW(*pValue);
+    *nValue = 2;
 
     return S_OK;
 }




More information about the wine-cvs mailing list