fixed a problem concerning static strings and dynamic structures...

This commit is contained in:
Marcel 2014-03-09 14:37:46 +00:00
parent ef9e018eef
commit 8608074638
1 changed files with 2 additions and 1 deletions

View File

@ -255,7 +255,8 @@ void CmdLO_AddElement(char*** target, unsigned int* counter, char* element) {
*target = malloc((cnt + 1) * sizeof(char*)); *target = malloc((cnt + 1) * sizeof(char*));
if (old != 0) if (old != 0)
memcpy(*target, old, (cnt) * sizeof(char*)); 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) if (old != 0)
free(old); free(old);
*counter = cnt + 1; *counter = cnt + 1;