mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-21 22:50:08 +03:00
malloc-fail: Report malloc failure in xmlFARegExec
This commit is contained in:
parent
b31813e60c
commit
3e7673bc2d
12
xmlregexp.c
12
xmlregexp.c
@ -3062,6 +3062,7 @@ xmlFARegExecSave(xmlRegExecCtxtPtr exec) {
|
||||
if (exec->rollbacks == NULL) {
|
||||
xmlRegexpErrMemory(NULL, "saving regexp");
|
||||
exec->maxRollbacks = 0;
|
||||
exec->status = XML_REGEXP_OUT_OF_MEMORY;
|
||||
return;
|
||||
}
|
||||
memset(exec->rollbacks, 0,
|
||||
@ -3076,6 +3077,7 @@ xmlFARegExecSave(xmlRegExecCtxtPtr exec) {
|
||||
if (tmp == NULL) {
|
||||
xmlRegexpErrMemory(NULL, "saving regexp");
|
||||
exec->maxRollbacks /= 2;
|
||||
exec->status = XML_REGEXP_OUT_OF_MEMORY;
|
||||
return;
|
||||
}
|
||||
exec->rollbacks = tmp;
|
||||
@ -3103,6 +3105,8 @@ xmlFARegExecSave(xmlRegExecCtxtPtr exec) {
|
||||
|
||||
static void
|
||||
xmlFARegExecRollBack(xmlRegExecCtxtPtr exec) {
|
||||
if (exec->status != XML_REGEXP_OK)
|
||||
return;
|
||||
if (exec->nbRollbacks <= 0) {
|
||||
exec->status = XML_REGEXP_NOT_FOUND;
|
||||
return;
|
||||
@ -3154,7 +3158,7 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
|
||||
exec->counts = (int *) xmlMalloc(comp->nbCounters * sizeof(int));
|
||||
if (exec->counts == NULL) {
|
||||
xmlRegexpErrMemory(NULL, "running regexp");
|
||||
return(-1);
|
||||
return(XML_REGEXP_OUT_OF_MEMORY);
|
||||
}
|
||||
memset(exec->counts, 0, comp->nbCounters * sizeof(int));
|
||||
} else
|
||||
@ -3253,6 +3257,8 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
|
||||
/* Save before incrementing */
|
||||
if (exec->state->nbTrans > exec->transno + 1) {
|
||||
xmlFARegExecSave(exec);
|
||||
if (exec->status != XML_REGEXP_OK)
|
||||
goto error;
|
||||
}
|
||||
if (trans->counter >= 0) {
|
||||
exec->counts[trans->counter]++;
|
||||
@ -3283,6 +3289,8 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
|
||||
exec->transno = -1; /* trick */
|
||||
exec->state = to;
|
||||
xmlFARegExecSave(exec);
|
||||
if (exec->status != XML_REGEXP_OK)
|
||||
goto error;
|
||||
exec->transno = transno;
|
||||
exec->state = state;
|
||||
}
|
||||
@ -3336,6 +3344,8 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
|
||||
((trans->count >= 0) && (deter == 0) &&
|
||||
(exec->state->nbTrans > exec->transno + 1))) {
|
||||
xmlFARegExecSave(exec);
|
||||
if (exec->status != XML_REGEXP_OK)
|
||||
goto error;
|
||||
}
|
||||
if (trans->counter >= 0) {
|
||||
xmlRegCounterPtr counter;
|
||||
|
Loading…
x
Reference in New Issue
Block a user