about summary refs log tree commit diff
path: root/posix/fnmatch_loop.c
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@redhat.com>2010-11-12 03:51:28 -0500
committerUlrich Drepper <drepper@gmail.com>2010-11-12 03:51:28 -0500
commit3540d66b669af54900b2e4bfc0ab82960e84a471 (patch)
tree2798b4dfa450db317e823ab8af0c2cdb2f340fa2 /posix/fnmatch_loop.c
parent13b695749acf88139a2ce1ed2c949e0e64300a9b (diff)
downloadglibc-3540d66b669af54900b2e4bfc0ab82960e84a471.tar.gz
glibc-3540d66b669af54900b2e4bfc0ab82960e84a471.tar.xz
glibc-3540d66b669af54900b2e4bfc0ab82960e84a471.zip
Fix memory leak in fnmatch
Diffstat (limited to 'posix/fnmatch_loop.c')
-rw-r--r--posix/fnmatch_loop.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/posix/fnmatch_loop.c b/posix/fnmatch_loop.c
index c8e52a6b4d..6b0224ea2c 100644
--- a/posix/fnmatch_loop.c
+++ b/posix/fnmatch_loop.c
@@ -1114,18 +1114,16 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
 	    int malloced = ! __libc_use_alloca (alloca_used + slen);	      \
 	    if (__builtin_expect (malloced, 0))				      \
 	      {								      \
-		newp = alloca_account (slen, alloca_used);		      \
-		any_malloced = 1;					      \
-	      }								      \
-	    else							      \
-	      {								      \
 		newp = malloc (slen);					      \
 		if (newp == NULL)					      \
 		  {							      \
 		    retval = -2;					      \
 		    goto out;						      \
 		  }							      \
+		any_malloced = 1;					      \
 	      }								      \
+	    else							      \
+	      newp = alloca_account (slen, alloca_used);		      \
 	    newp->next = NULL;						      \
 	    newp->malloced = malloced;					      \
 	    *((CHAR *) MEMPCPY (newp->str, startp, p - startp)) = L('\0');    \