From 86080746384b86e74a384b637bca90733204fb39 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 9 Mar 2014 14:37:46 +0000 Subject: [PATCH] fixed a problem concerning static strings and dynamic structures... --- c/cmdlineoptions.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/c/cmdlineoptions.c b/c/cmdlineoptions.c index b3e5ca5..df0d130 100644 --- a/c/cmdlineoptions.c +++ b/c/cmdlineoptions.c @@ -255,7 +255,8 @@ void CmdLO_AddElement(char*** target, unsigned int* counter, char* element) { *target = malloc((cnt + 1) * sizeof(char*)); if (old != 0) memcpy(*target, old, (cnt) * sizeof(char*)); - *(*target + cnt) = element; + *(*target + cnt) = malloc(strlen(element) * sizeof(char)); + memcpy(*(*target + cnt), element, strlen(element)); if (old != 0) free(old); *counter = cnt + 1;