wbemprox: Avoid a crash when serializing object text.

This commit is contained in:
Hans Leidekker 2012-11-02 15:34:27 +01:00 committed by Alexandre Julliard
parent 815031d832
commit 6955b09023
2 changed files with 13 additions and 8 deletions

View File

@ -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;
}

View File

@ -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 );