mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-27 18:50:07 +03:00
malloc-fail: Fix null deref if growing input buffer fails
Also add some error checks. Found with libFuzzer, see #344.
This commit is contained in:
parent
0c5f40b788
commit
2355eac59e
@ -2332,7 +2332,8 @@ xmlCharEncInput(xmlParserInputBufferPtr input, int flush)
|
||||
toconv = 64 * 1024;
|
||||
written = xmlBufAvail(out);
|
||||
if (toconv * 2 >= written) {
|
||||
xmlBufGrow(out, toconv * 2);
|
||||
if (xmlBufGrow(out, toconv * 2) < 0)
|
||||
return (-1);
|
||||
written = xmlBufAvail(out);
|
||||
}
|
||||
if ((written > 128 * 1024) && (flush == 0))
|
||||
|
@ -315,6 +315,12 @@ xmlParserInputGrow(xmlParserInputPtr in, int len) {
|
||||
ret = xmlParserInputBufferGrow(in->buf, len);
|
||||
|
||||
in->base = xmlBufContent(in->buf->buffer);
|
||||
if (in->base == NULL) {
|
||||
in->base = BAD_CAST "";
|
||||
in->cur = in->base;
|
||||
in->end = in->base;
|
||||
return(-1);
|
||||
}
|
||||
in->cur = in->base + indx;
|
||||
in->end = xmlBufEnd(in->buf->buffer);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user