changeset 2871:5f06dc569da7 draft

Fix a memory error.
author Roy Marples <roy@marples.name>
date Wed, 26 Nov 2014 15:34:14 +0000
parents d22f08d56f00
children 95be45730a6e
files script.c
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/script.c	Wed Nov 26 15:01:30 2014 +0000
+++ b/script.c	Wed Nov 26 15:34:14 2014 +0000
@@ -288,8 +288,8 @@
 		elen = 13;
 
 #define EMALLOC(i, l) if ((env[(i)] = malloc((l))) == NULL) goto eexit;
-	/* Make our env */
-	env = calloc(1, sizeof(char *) * (elen + 1));
+	/* Make our env + space for profile, wireless and debug */
+	env = calloc(1, sizeof(char *) * (elen + 3 + 1));
 	if (env == NULL)
 		goto eexit;
 	e = strlen("interface") + strlen(ifp->name) + 2;
@@ -378,7 +378,7 @@
 		snprintf(env[elen++], e, "syslog_debug=true");
 	}
 	if (*ifp->profile) {
-		e = strlen("profile=") + strlen(ifp->profile) + 2;
+		e = strlen("profile=") + strlen(ifp->profile) + 1;
 		EMALLOC(elen, e);
 		snprintf(env[elen++], e, "profile=%s", ifp->profile);
 	}