[PATCH 1/2] oleaut32: Typelib strings of size -1 are NULL
Andrew Eikum
aeikum at codeweavers.com
Mon Sep 9 08:45:07 CDT 2013
Commit 24dd931a56e59dcf6a44a7fc15a530353bcb9c31 introduced this
behavior, but I don't know why.
With the typelib I'm using (VBE6.DLL from MSO2k7), the size is -1 and
the following string is empty. Windows 7 results in a NULL pointer from
this combination, and manually inserting a NULL-terminated string into
the typelib file doesn't change that behavior.
---
dlls/oleaut32/typelib.c | 29 +++++++++++------------------
1 file changed, 11 insertions(+), 18 deletions(-)
diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c
index 18c1e19..0012b96 100644
--- a/dlls/oleaut32/typelib.c
+++ b/dlls/oleaut32/typelib.c
@@ -2258,24 +2258,17 @@ static void MSFT_ReadValue( VARIANT * pVar, int offset, TLBContext *pcx )
case VT_BSTR :{
char * ptr;
MSFT_ReadLEDWords(&size, sizeof(INT), pcx, DO_NOT_SEEK );
- if(size < 0) {
- char next;
- DWORD origPos = MSFT_Tell(pcx), nullPos;
-
- do {
- MSFT_Read(&next, 1, pcx, DO_NOT_SEEK);
- } while (next);
- nullPos = MSFT_Tell(pcx);
- size = nullPos - origPos;
- MSFT_Seek(pcx, origPos);
- }
- ptr = heap_alloc_zero(size);/* allocate temp buffer */
- MSFT_Read(ptr, size, pcx, DO_NOT_SEEK);/* read string (ANSI) */
- V_BSTR(pVar)=SysAllocStringLen(NULL,size);
- /* FIXME: do we need a AtoW conversion here? */
- V_UNION(pVar, bstrVal[size])='\0';
- while(size--) V_UNION(pVar, bstrVal[size])=ptr[size];
- heap_free(ptr);
+ if(size < 0){
+ V_BSTR(pVar) = NULL;
+ }else{
+ ptr = heap_alloc_zero(size);
+ MSFT_Read(ptr, size, pcx, DO_NOT_SEEK);
+ V_BSTR(pVar)=SysAllocStringLen(NULL,size);
+ /* FIXME: do we need a AtoW conversion here? */
+ V_UNION(pVar, bstrVal[size])='\0';
+ while(size--) V_UNION(pVar, bstrVal[size])=ptr[size];
+ heap_free(ptr);
+ }
}
size=-4; break;
/* FIXME: this will not work AT ALL when the variant contains a pointer */
--
1.8.4
More information about the wine-patches
mailing list