Commit 24dd931a authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

oleaut32: Handle bstr length of -1 in typelibs.

parent bf680011
...@@ -1367,12 +1367,13 @@ static void *TLB_CopyTypeDesc( TYPEDESC *dest, const TYPEDESC *src, void *buffer ...@@ -1367,12 +1367,13 @@ static void *TLB_CopyTypeDesc( TYPEDESC *dest, const TYPEDESC *src, void *buffer
* *
* Functions for reading MSFT typelibs (those created by CreateTypeLib2) * Functions for reading MSFT typelibs (those created by CreateTypeLib2)
*/ */
/* read function */ static inline unsigned int MSFT_Tell(TLBContext *pcx)
static DWORD MSFT_Read(void *buffer, DWORD count, TLBContext *pcx, long where )
{ {
TRACE_(typelib)("pos=0x%08x len=0x%08lx 0x%08x 0x%08x 0x%08lx\n", return pcx->pos;
pcx->pos, count, pcx->oStart, pcx->length, where); }
static inline void MSFT_Seek(TLBContext *pcx, long where)
{
if (where != DO_NOT_SEEK) if (where != DO_NOT_SEEK)
{ {
where += pcx->oStart; where += pcx->oStart;
...@@ -1384,6 +1385,15 @@ static DWORD MSFT_Read(void *buffer, DWORD count, TLBContext *pcx, long where ) ...@@ -1384,6 +1385,15 @@ static DWORD MSFT_Read(void *buffer, DWORD count, TLBContext *pcx, long where )
} }
pcx->pos = where; pcx->pos = where;
} }
}
/* read function */
static DWORD MSFT_Read(void *buffer, DWORD count, TLBContext *pcx, long where )
{
TRACE_(typelib)("pos=0x%08x len=0x%08lx 0x%08x 0x%08x 0x%08lx\n",
pcx->pos, count, pcx->oStart, pcx->length, where);
MSFT_Seek(pcx, where);
if (pcx->pos + count > pcx->length) count = pcx->length - pcx->pos; if (pcx->pos + count > pcx->length) count = pcx->length - pcx->pos;
memcpy( buffer, (char *)pcx->mapping + pcx->pos, count ); memcpy( buffer, (char *)pcx->mapping + pcx->pos, count );
pcx->pos += count; pcx->pos += count;
...@@ -1561,16 +1571,23 @@ static void MSFT_ReadValue( VARIANT * pVar, int offset, TLBContext *pcx ) ...@@ -1561,16 +1571,23 @@ static void MSFT_ReadValue( VARIANT * pVar, int offset, TLBContext *pcx )
char * ptr; char * ptr;
MSFT_ReadLEDWords(&size, sizeof(INT), pcx, DO_NOT_SEEK ); MSFT_ReadLEDWords(&size, sizeof(INT), pcx, DO_NOT_SEEK );
if(size < 0) { if(size < 0) {
FIXME("BSTR length = %d?\n", size); char next;
} else { DWORD origPos = MSFT_Tell(pcx), nullPos;
ptr=TLB_Alloc(size);/* allocate temp buffer */
MSFT_Read(ptr, size, pcx, DO_NOT_SEEK);/* read string (ANSI) */ do {
V_BSTR(pVar)=SysAllocStringLen(NULL,size); MSFT_Read(&next, 1, pcx, DO_NOT_SEEK);
/* FIXME: do we need a AtoW conversion here? */ } while (next);
V_UNION(pVar, bstrVal[size])=L'\0'; nullPos = MSFT_Tell(pcx);
while(size--) V_UNION(pVar, bstrVal[size])=ptr[size]; size = nullPos - origPos;
TLB_Free(ptr); MSFT_Seek(pcx, origPos);
} }
ptr=TLB_Alloc(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])=L'\0';
while(size--) V_UNION(pVar, bstrVal[size])=ptr[size];
TLB_Free(ptr);
} }
size=-4; break; size=-4; break;
/* FIXME: this will not work AT ALL when the variant contains a pointer */ /* FIXME: this will not work AT ALL when the variant contains a pointer */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment