From cfbebadc603ad85459bd6f189c192d3ad44f6b43 Mon Sep 17 00:00:00 2001 From: Xin LI Date: Fri, 19 Dec 2014 06:48:47 +0000 Subject: [PATCH] Plug a memory leak. Obtained from: DragonFlyBSD (commit 5119ece) MFC after: 2 weeks --- lib/libc/regex/regcomp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c index a01bb95931b..2ecb88c54a9 100644 --- a/lib/libc/regex/regcomp.c +++ b/lib/libc/regex/regcomp.c @@ -1716,8 +1716,10 @@ computematchjumps(struct parse *p, struct re_guts *g) } g->matchjump = (int*) malloc(g->mlen * sizeof(unsigned int)); - if (g->matchjump == NULL) /* Not a fatal error */ + if (g->matchjump == NULL) { /* Not a fatal error */ + free(pmatches); return; + } /* Set maximum possible jump for each character in the pattern */ for (mindex = 0; mindex < g->mlen; mindex++)