mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-23 02:50:08 +03:00
malloc-fail: Fix null-deref in xmlPatPushState
This commit is contained in:
parent
a530ff125d
commit
6e1e22dc5f
11
pattern.c
11
pattern.c
@ -433,16 +433,11 @@ xmlReversePattern(xmlPatternPtr comp) {
|
||||
|
||||
static int
|
||||
xmlPatPushState(xmlStepStates *states, int step, xmlNodePtr node) {
|
||||
if ((states->states == NULL) || (states->maxstates <= 0)) {
|
||||
states->maxstates = 4;
|
||||
states->nbstates = 0;
|
||||
states->states = xmlMalloc(4 * sizeof(xmlStepState));
|
||||
}
|
||||
else if (states->maxstates <= states->nbstates) {
|
||||
if (states->maxstates <= states->nbstates) {
|
||||
size_t newSize = states->maxstates ? states->maxstates * 2 : 4;
|
||||
xmlStepState *tmp;
|
||||
|
||||
tmp = (xmlStepStatePtr) xmlRealloc(states->states,
|
||||
2 * states->maxstates * sizeof(xmlStepState));
|
||||
tmp = xmlRealloc(states->states, newSize * sizeof(tmp[0]));
|
||||
if (tmp == NULL)
|
||||
return(-1);
|
||||
states->states = tmp;
|
||||
|
Loading…
x
Reference in New Issue
Block a user