diff --git a/buf.c b/buf.c index a7eb2e8f60ba37e7dffdfc4fb311651822a5ccc5..3c293855ce236b2fdcd7e47b9897f7caa2fc5915 100644 --- a/buf.c +++ b/buf.c @@ -172,8 +172,8 @@ xmlBufCreateSize(size_t size) { ret->error = 0; ret->buffer = NULL; ret->alloc = xmlBufferAllocScheme; - ret->size = (size ? size+1 : 0); /* +1 for ending null */ - ret->compat_size = (int) ret->size; + ret->size = (size ? size + 1 : 0); /* +1 for ending null */ + ret->compat_size = (ret->size > INT_MAX ? INT_MAX : ret->size); if (ret->size){ ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar)); if (ret->content == NULL) {