mirror of
https://gitlab.gnome.org/GNOME/libxml2
synced 2025-03-28 21:33:13 +00:00
encoding: Check reallocations for overflow
This commit is contained in:
parent
1c51f3d3f1
commit
df0f16fa26
13
encoding.c
13
encoding.c
@ -45,6 +45,7 @@
|
|||||||
#include "private/enc.h"
|
#include "private/enc.h"
|
||||||
#include "private/entities.h"
|
#include "private/entities.h"
|
||||||
#include "private/error.h"
|
#include "private/error.h"
|
||||||
|
#include "private/memory.h"
|
||||||
|
|
||||||
#ifdef LIBXML_ICU_ENABLED
|
#ifdef LIBXML_ICU_ENABLED
|
||||||
#include <unicode/ucnv.h>
|
#include <unicode/ucnv.h>
|
||||||
@ -424,13 +425,13 @@ xmlAddEncodingAlias(const char *name, const char *alias) {
|
|||||||
|
|
||||||
if (xmlCharEncodingAliasesNb >= xmlCharEncodingAliasesMax) {
|
if (xmlCharEncodingAliasesNb >= xmlCharEncodingAliasesMax) {
|
||||||
xmlCharEncodingAliasPtr tmp;
|
xmlCharEncodingAliasPtr tmp;
|
||||||
size_t newSize = xmlCharEncodingAliasesMax ?
|
int newSize;
|
||||||
xmlCharEncodingAliasesMax * 2 :
|
|
||||||
20;
|
|
||||||
|
|
||||||
tmp = (xmlCharEncodingAliasPtr)
|
newSize = xmlGrowCapacity(xmlCharEncodingAliasesMax, sizeof(tmp[0]),
|
||||||
xmlRealloc(xmlCharEncodingAliases,
|
20, XML_MAX_ITEMS);
|
||||||
newSize * sizeof(xmlCharEncodingAlias));
|
if (newSize < 0)
|
||||||
|
return(-1);
|
||||||
|
tmp = xmlRealloc(xmlCharEncodingAliases, newSize * sizeof(tmp[0]));
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
return(-1);
|
return(-1);
|
||||||
xmlCharEncodingAliases = tmp;
|
xmlCharEncodingAliases = tmp;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user