Issue #218 - Do NOT allocate a 1 byte null String buffer.
This is when setting a String config value through say tidyOptSetValue using say tidyOptSetValue(tdoc,id,""). If the length of the new string is zero then do not allocate a 1 byte buffer, set it to 0, for the option. Any previous buffer has already been released. This means API functions like tidyOptSaveSink will not return erroneous null String values!
This commit is contained in:
parent
3f72b6e335
commit
18880eab55
|
@ -379,7 +379,10 @@ static Bool SetOptionValue( TidyDocImpl* doc, TidyOptionId optId, ctmbstr val )
|
||||||
{
|
{
|
||||||
assert( option->id == optId && option->type == TidyString );
|
assert( option->id == optId && option->type == TidyString );
|
||||||
FreeOptionValue( doc, option, &doc->config.value[ optId ] );
|
FreeOptionValue( doc, option, &doc->config.value[ optId ] );
|
||||||
|
if ( TY_(tmbstrlen)(val)) /* Issue #218 - ONLY if it has LENGTH! */
|
||||||
doc->config.value[ optId ].p = TY_(tmbstrdup)( doc->allocator, val );
|
doc->config.value[ optId ].p = TY_(tmbstrdup)( doc->allocator, val );
|
||||||
|
else
|
||||||
|
doc->config.value[ optId ].p = 0; /* should already be zero, but to be sure... */
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue