Prevent unneeded memory allocation for language tags in libwc
cf. https://oss-fuzz.com/testcase-detail/6275874304425984 Bug-Chromium: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=31397
This commit is contained in:
@@ -702,8 +702,13 @@ wtf_push_ucs(Str os, wc_uint32 ucs, wc_status *st)
|
|||||||
if (! WcOption.use_language_tag)
|
if (! WcOption.use_language_tag)
|
||||||
return;
|
return;
|
||||||
if (ucs == WC_C_LANGUAGE_TAG)
|
if (ucs == WC_C_LANGUAGE_TAG)
|
||||||
|
if (st->tag)
|
||||||
|
Strclear(st->tag);
|
||||||
|
else
|
||||||
st->tag = Strnew_size(MAX_TAG_LEN);
|
st->tag = Strnew_size(MAX_TAG_LEN);
|
||||||
else if (ucs == WC_C_CANCEL_TAG) {
|
else if (ucs == WC_C_CANCEL_TAG) {
|
||||||
|
if (st->tag)
|
||||||
|
Strfree(st->tag);
|
||||||
st->tag = NULL;
|
st->tag = NULL;
|
||||||
st->ntag = 0;
|
st->ntag = 0;
|
||||||
} else if (st->tag && st->tag->length < MAX_TAG_LEN &&
|
} else if (st->tag && st->tag->length < MAX_TAG_LEN &&
|
||||||
|
Reference in New Issue
Block a user