mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-21 14:53:44 +03:00
valid: Report malloc failure after xmlRegExecPushString
This commit is contained in:
13
xmlregexp.c
13
xmlregexp.c
@@ -3500,7 +3500,7 @@ xmlRegFreeExecCtxt(xmlRegExecCtxtPtr exec) {
|
||||
xmlFree(exec);
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
xmlRegExecSetErrString(xmlRegExecCtxtPtr exec, const xmlChar *value) {
|
||||
if (exec->errString != NULL)
|
||||
xmlFree(exec->errString);
|
||||
@@ -3508,9 +3508,12 @@ xmlRegExecSetErrString(xmlRegExecCtxtPtr exec, const xmlChar *value) {
|
||||
exec->errString = NULL;
|
||||
} else {
|
||||
exec->errString = xmlStrdup(value);
|
||||
if (exec->errString == NULL)
|
||||
if (exec->errString == NULL) {
|
||||
exec->status = XML_REGEXP_OUT_OF_MEMORY;
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3917,7 +3920,8 @@ xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value,
|
||||
* entering a sink state, save the current state as error
|
||||
* state.
|
||||
*/
|
||||
xmlRegExecSetErrString(exec, value);
|
||||
if (xmlRegExecSetErrString(exec, value) < 0)
|
||||
break;
|
||||
exec->errState = exec->state;
|
||||
memcpy(exec->errCounts, exec->counts,
|
||||
exec->comp->nbCounters * sizeof(int));
|
||||
@@ -3954,7 +3958,8 @@ rollback:
|
||||
if ((progress) && (exec->state != NULL) &&
|
||||
(exec->state->type != XML_REGEXP_SINK_STATE)) {
|
||||
progress = 0;
|
||||
xmlRegExecSetErrString(exec, value);
|
||||
if (xmlRegExecSetErrString(exec, value) < 0)
|
||||
break;
|
||||
exec->errState = exec->state;
|
||||
if (exec->comp->nbCounters)
|
||||
memcpy(exec->errCounts, exec->counts,
|
||||
|
Reference in New Issue
Block a user