Commit 6955b090 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

wbemprox: Avoid a crash when serializing object text.

parent 815031d8
......@@ -568,19 +568,23 @@ static BSTR get_body_text( const struct table *table, UINT row, UINT *len )
*len = 0;
for (i = 0; i < table->num_cols; i++)
{
*len += sizeof(fmtW) / sizeof(fmtW[0]);
*len += strlenW( table->columns[i].name );
value = get_value_bstr( table, row, i );
*len += SysStringLen( value );
SysFreeString( value );
if ((value = get_value_bstr( table, row, i )))
{
*len += sizeof(fmtW) / sizeof(fmtW[0]);
*len += strlenW( table->columns[i].name );
*len += SysStringLen( value );
SysFreeString( value );
}
}
if (!(ret = SysAllocStringLen( NULL, *len ))) return NULL;
p = ret;
for (i = 0; i < table->num_cols; i++)
{
value = get_value_bstr( table, row, i );
p += sprintfW( p, fmtW, table->columns[i].name, value );
SysFreeString( value );
if ((value = get_value_bstr( table, row, i )))
{
p += sprintfW( p, fmtW, table->columns[i].name, value );
SysFreeString( value );
}
}
return ret;
}
......
......@@ -166,6 +166,7 @@ BSTR get_value_bstr( const struct table *table, UINT row, UINT column )
case CIM_DATETIME:
case CIM_STRING:
if (!val) return NULL;
len = strlenW( (const WCHAR *)(INT_PTR)val ) + 2;
if (!(ret = SysAllocStringLen( NULL, len ))) return NULL;
sprintfW( ret, fmt_strW, (const WCHAR *)(INT_PTR)val );
......
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