about summary refs log tree commit diff
path: root/nscd
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-05-31 08:45:44 -0400
committerUlrich Drepper <drepper@gmail.com>2011-05-31 08:45:44 -0400
commitc8fc0c91695b1c7003c7170861274161f9224817 (patch)
tree70ef7eccf7a99d4282377aabcbc1bd0e8f14a6e7 /nscd
parent356f8bc660a154a07b03da7c536831da5c8f74fe (diff)
downloadglibc-c8fc0c91695b1c7003c7170861274161f9224817.tar.gz
glibc-c8fc0c91695b1c7003c7170861274161f9224817.tar.xz
glibc-c8fc0c91695b1c7003c7170861274161f9224817.zip
Don't free non-malloced memory and fix memory leak glibc-2.14.9000
Diffstat (limited to 'nscd')
-rw-r--r--nscd/nscd_getserv_r.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/nscd/nscd_getserv_r.c b/nscd/nscd_getserv_r.c
index de96a5757b..f9ef0565d8 100644
--- a/nscd/nscd_getserv_r.c
+++ b/nscd/nscd_getserv_r.c
@@ -124,6 +124,7 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto,
 	  s_name = (char *) (&found->data[0].servdata + 1);
 	  serv_resp = found->data[0].servdata;
 	  s_proto = s_name + serv_resp.s_name_len;
+	  alloca_aliases_len = 1;
 	  aliases_len = (uint32_t *) (s_proto + serv_resp.s_proto_len);
 	  aliases_list = ((char *) aliases_len
 			  + serv_resp.s_aliases_cnt * sizeof (uint32_t));
@@ -154,7 +155,9 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto,
 				     + (serv_resp.s_aliases_cnt
 					* sizeof (uint32_t)));
 	      if (alloca_aliases_len)
-		tmp = __alloca (serv_resp.s_aliases_cnt * sizeof (uint32_t));
+		tmp = alloca_account (serv_resp.s_aliases_cnt
+				      * sizeof (uint32_t),
+				      alloca_used);
 	      else
 		{
 		  tmp = malloc (serv_resp.s_aliases_cnt * sizeof (uint32_t));
@@ -249,8 +252,9 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto,
 				     + (serv_resp.s_aliases_cnt
 					* sizeof (uint32_t)));
 	      if (alloca_aliases_len)
-		aliases_len = alloca (serv_resp.s_aliases_cnt
-				      * sizeof (uint32_t));
+		aliases_len = alloca_account (serv_resp.s_aliases_cnt
+					      * sizeof (uint32_t),
+					      alloca_used);
 	      else
 		{
 		  aliases_len = malloc (serv_resp.s_aliases_cnt
@@ -368,7 +372,11 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto,
 	}
 
       if (retval != -1)
-	goto retry;
+	{
+	  if (!alloca_aliases_len)
+	    free (aliases_len);
+	  goto retry;
+	}
     }
 
   if (!alloca_aliases_len)