diff options
author | Christian Hesse <mail@eworm.de> | 2018-08-28 18:23:36 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2018-08-28 20:34:08 +0200 |
commit | 587d9755a3977cc1b0cc390043ad6e362da56471 (patch) | |
tree | b3acb17b6535dadb71d13e43b749fb86a0a1b3e0 | |
parent | b6ce4927a35313af0b17713b834d0ffe0dd17fbc (diff) | |
download | cgit-587d9755a3977cc1b0cc390043ad6e362da56471.tar.gz |
ui-ssdiff: ban strcat()
Git upstream bans strcat() with commit:
banned.h: mark strcat() as banned
1b11b64b815db62f93a04242e4aed5687a448748
-rw-r--r-- | ui-ssdiff.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ui-ssdiff.c b/ui-ssdiff.c index a3dd059..c456033 100644 --- a/ui-ssdiff.c +++ b/ui-ssdiff.c @@ -117,6 +117,7 @@ static char *replace_tabs(char *line) int n_tabs = 0; int i; char *result; + int result_len; if (linelen == 0) { result = xmalloc(1); @@ -128,13 +129,14 @@ static char *replace_tabs(char *line) if (line[i] == '\t') n_tabs += 1; } - result = xmalloc(linelen + n_tabs * 8 + 1); + result_len = linelen + n_tabs * 8; + result = xmalloc(result_len + 1); result[0] = '\0'; for (;;) { cur_buf = strchr(prev_buf, '\t'); if (!cur_buf) { - strcat(result, prev_buf); + strncat(result, prev_buf, result_len); break; } else { strncat(result, prev_buf, cur_buf - prev_buf); |