jaehwan pushed a commit to branch master. http://git.enlightenment.org/tools/eflete.git/commit/?id=4c7526dbc4f8de87ed86a003da7c9aa65d24a679
commit 4c7526dbc4f8de87ed86a003da7c9aa65d24a679 Author: Jaehwan Kim <[email protected]> Date: Fri Dec 9 17:47:35 2016 +0900 string: fix the allocation error. --- src/bin/common/string_common.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/bin/common/string_common.c b/src/bin/common/string_common.c index 712a0c9..1c4cb51 100644 --- a/src/bin/common/string_common.c +++ b/src/bin/common/string_common.c @@ -103,19 +103,21 @@ string_backslash_insert(const char *str, char src) { assert(str != NULL); char *dst; - int i = 0; - int count = 1; + int i = 0, count = 1; - dst = mem_malloc((strlen(str) + count) * sizeof(char)); + for (i = 0; i < strlen(str); i++) + if (str[i] == src) + count++; + dst = mem_calloc(strlen(str) + count, sizeof(char)); + + i = 0; while (*str != '\0') { if (*str != src) dst[i] = *str; else { - count++; - dst = mem_malloc((strlen(str) + count) * sizeof(char)); dst[i++] = '\\'; dst[i] = src; } --
