From 23df5d392a47ef3a4eb9d6edffb7413f24ada61a Mon Sep 17 00:00:00 2001 From: Manu Garg Date: Tue, 1 Sep 2015 11:59:49 -0700 Subject: [PATCH] Fix off-by-one error in allocating space for copy of a string. --- src/pac_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pac_utils.h b/src/pac_utils.h index 885158c7..cb079e46 100644 --- a/src/pac_utils.h +++ b/src/pac_utils.h @@ -336,7 +336,7 @@ static const char *pacUtils = // You must free the result if result is non-NULL. char *str_replace(const char *orig, char *rep, char *with) { - char *tmporig = (char*) malloc(strlen(orig)); // Copy of orig that we work with + char *tmporig = malloc(strlen(orig) + 1); // Copy of orig that we work with tmporig = strcpy(tmporig, orig); char *result; // the return string