diff --git a/buf.c b/buf.c index c7e51005fe4b43f3bb6d2f7991354da78cb9f0a1..ab7c402318f81638ecaaeedf582214d2461cafaf 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) {