changeset 4979:2881fac3aa3e

6249663 memory leak in libnsl
author dm199272
date Fri, 31 Aug 2007 23:14:51 -0700
parents 7bb29ac056b9
children de2c9c980ea7
files usr/src/lib/libnsl/ipsec/algs.c
diffstat 1 files changed, 10 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/lib/libnsl/ipsec/algs.c	Fri Aug 31 17:00:55 2007 -0700
+++ b/usr/src/lib/libnsl/ipsec/algs.c	Fri Aug 31 23:14:51 2007 -0700
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -139,8 +139,10 @@
 		num_sizes = 0;
 
 		token = strtok_r(input_string, comma, &lasts);
-		if (token == NULL || key_sizes == NULL)
+		if (token == NULL) {
+			free(key_sizes);
 			return (-1);
+		}
 		*key_sizes = 0;
 		do {
 			int *nks;
@@ -218,7 +220,7 @@
 				continue;
 			} else {
 				(void) snprintf(diag_buf, sizeof (diag_buf),
-					"non-recognized start of line");
+				    "non-recognized start of line");
 				goto bail;
 			}
 		}
@@ -467,9 +469,9 @@
 					goto bail;
 
 				new_proto->proto_algs_pkgs[npkgs].alg_num =
-					curalg->a_alg_num;
+				    curalg->a_alg_num;
 				new_proto->proto_algs_pkgs[npkgs].pkg_name =
-					strdup(cur_pkg);
+				    strdup(cur_pkg);
 				if (new_proto->proto_algs_pkgs[npkgs].pkg_name
 				    == NULL)
 					goto bail;
@@ -565,8 +567,7 @@
 		 * surface check fails.
 		 */
 		if (stat(INET_IPSECALGSFILE, &statbuf) == -1 ||
-		    (statbuf.st_mtime < proto_last_update &&
-			protos != NULL))
+		    (statbuf.st_mtime < proto_last_update && protos != NULL))
 			return;
 		(void) rw_wrlock(&proto_rw);
 	}
@@ -658,7 +659,8 @@
 		return (NULL);
 
 	/* count number of elements in source array */
-	for (swalker = orig; *swalker != NULL; swalker++);
+	for (swalker = orig; *swalker != NULL; swalker++)
+		;
 
 	/* use calloc() to get NULL-initialization */
 	newbie = calloc(swalker - orig + 1, sizeof (char *));