Avoid realloc(NULL, n)

This commit is contained in:
James Clark 1998-06-27 02:12:47 +00:00
parent 2844be94b7
commit 34b47abda7

View file

@ -550,7 +550,7 @@ int XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
if (nLeftOver) {
if (buffer == 0 || nLeftOver > bufferLim - buffer) {
/* FIXME avoid integer overflow */
buffer = realloc(buffer, len * 2);
buffer = buffer == 0 ? malloc(len * 2) : realloc(buffer, len * 2);
if (!buffer) {
errorCode = XML_ERROR_NO_MEMORY;
eventPtr = eventEndPtr = 0;