mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-27 18:50:07 +03:00
malloc-fail: Check for malloc failure in xmlFindCharEncodingHandler
Don't return encoding handlers with a NULL name. Found with libFuzzer, see #344.
This commit is contained in:
parent
d18f9c1102
commit
1c5e1fc194
12
encoding.c
12
encoding.c
@ -1793,6 +1793,12 @@ xmlFindCharEncodingHandler(const char *name) {
|
||||
}
|
||||
memset(enc, 0, sizeof(xmlCharEncodingHandler));
|
||||
enc->name = xmlMemStrdup(name);
|
||||
if (enc->name == NULL) {
|
||||
xmlFree(enc);
|
||||
iconv_close(icv_in);
|
||||
iconv_close(icv_out);
|
||||
return(NULL);
|
||||
}
|
||||
enc->input = NULL;
|
||||
enc->output = NULL;
|
||||
enc->iconv_in = icv_in;
|
||||
@ -1825,6 +1831,12 @@ xmlFindCharEncodingHandler(const char *name) {
|
||||
}
|
||||
memset(encu, 0, sizeof(xmlCharEncodingHandler));
|
||||
encu->name = xmlMemStrdup(name);
|
||||
if (encu->name == NULL) {
|
||||
xmlFree(encu);
|
||||
closeIcuConverter(ucv_in);
|
||||
closeIcuConverter(ucv_out);
|
||||
return(NULL);
|
||||
}
|
||||
encu->input = NULL;
|
||||
encu->output = NULL;
|
||||
encu->uconv_in = ucv_in;
|
||||
|
Loading…
x
Reference in New Issue
Block a user