1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-27 18:50:07 +03:00

regexp: Add sanity check in xmlRegCalloc2

These arguments should be non-zero, but add a sanity check to avoid
division by zero.

Fixes #450.
This commit is contained in:
Nick Wellnhofer 2023-02-21 15:24:19 +01:00
parent c9e4c6d416
commit 85057e5131

View File

@ -436,7 +436,8 @@ xmlRegCalloc2(size_t dim1, size_t dim2, size_t elemSize) {
void *ret;
/* Check for overflow */
if (dim1 > SIZE_MAX / dim2 / elemSize)
if ((dim2 == 0) || (elemSize == 0) ||
(dim1 > SIZE_MAX / dim2 / elemSize))
return (NULL);
totalSize = dim1 * dim2 * elemSize;
ret = xmlMalloc(totalSize);