summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cregex.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/cregex.c b/src/cregex.c
index 0688d9e1..a1d43944 100644
--- a/src/cregex.c
+++ b/src/cregex.c
@@ -842,16 +842,17 @@ _bldcclass(_Parser *par)
static _Reprog*
-_regcomp1(_Reprog *progp, _Parser *par, const char *s, int cflags)
+_regcomp1(_Reprog *pp, _Parser *par, const char *s, int cflags)
{
_Token token;
/* get memory for the program. estimated max usage */
par->instcap = 5U + 6*strlen(s);
- _Reprog* pp = (_Reprog *)c_realloc(progp, sizeof(_Reprog) + par->instcap*sizeof(_Reinst));
- if (pp == NULL) {
+ _Reprog* old_pp = pp;
+ pp = (_Reprog *)c_realloc(pp, sizeof(_Reprog) + par->instcap*sizeof(_Reinst));
+ if (! pp) {
+ c_free(old_pp);
par->error = CREG_OUTOFMEMORY;
- c_free(progp);
return NULL;
}
pp->flags.icase = (cflags & CREG_C_ICASE) != 0;