diff --git a/xmlregexp.c b/xmlregexp.c index 59dbef6a..2f811031 100644 --- a/xmlregexp.c +++ b/xmlregexp.c @@ -5603,7 +5603,7 @@ xmlRegexpPrint(FILE *output, xmlRegexpPtr regexp) { */ xmlRegexpPtr xmlRegexpCompile(const xmlChar *regexp) { - xmlRegexpPtr ret; + xmlRegexpPtr ret = NULL; xmlRegParserCtxtPtr ctxt; ctxt = xmlRegNewParserCtxt(regexp); @@ -5613,7 +5613,7 @@ xmlRegexpCompile(const xmlChar *regexp) { /* initialize the parser */ ctxt->state = xmlRegStatePush(ctxt); if (ctxt->state == NULL) - return(NULL); + goto error; ctxt->start = ctxt->state; ctxt->end = NULL; @@ -5622,10 +5622,8 @@ xmlRegexpCompile(const xmlChar *regexp) { if (CUR != 0) { ERROR("xmlFAParseRegExp: extra characters"); } - if (ctxt->error != 0) { - xmlRegFreeParserCtxt(ctxt); - return(NULL); - } + if (ctxt->error != 0) + goto error; ctxt->end = ctxt->state; ctxt->start->type = XML_REGEXP_START_STATE; ctxt->end->type = XML_REGEXP_FINAL_STATE; @@ -5634,11 +5632,11 @@ xmlRegexpCompile(const xmlChar *regexp) { xmlFAEliminateEpsilonTransitions(ctxt); - if (ctxt->error != 0) { - xmlRegFreeParserCtxt(ctxt); - return(NULL); - } + if (ctxt->error != 0) + goto error; ret = xmlRegEpxFromParse(ctxt); + +error: xmlRegFreeParserCtxt(ctxt); return(ret); }