about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ui-ssdiff.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/ui-ssdiff.c b/ui-ssdiff.c index b6dc5b0..af8bc9e 100644 --- a/ui-ssdiff.c +++ b/ui-ssdiff.c
@@ -117,7 +117,7 @@ static char *replace_tabs(char *line)
117 int n_tabs = 0; 117 int n_tabs = 0;
118 int i; 118 int i;
119 char *result; 119 char *result;
120 int result_len; 120 size_t result_len;
121 121
122 if (linelen == 0) { 122 if (linelen == 0) {
123 result = xmalloc(1); 123 result = xmalloc(1);
@@ -136,10 +136,12 @@ static char *replace_tabs(char *line)
136 for (;;) { 136 for (;;) {
137 cur_buf = strchr(prev_buf, '\t'); 137 cur_buf = strchr(prev_buf, '\t');
138 if (!cur_buf) { 138 if (!cur_buf) {
139 strncat(result, prev_buf, result_len); 139 linelen = strlen(result);
140 strlcpy(&result[linelen], prev_buf, result_len - linelen + 1);
140 break; 141 break;
141 } else { 142 } else {
142 strncat(result, prev_buf, cur_buf - prev_buf); 143 linelen = strlen(result);
144 strlcpy(&result[linelen], prev_buf, cur_buf - prev_buf + 1);
143 linelen = strlen(result); 145 linelen = strlen(result);
144 memset(&result[linelen], ' ', 8 - (linelen % 8)); 146 memset(&result[linelen], ' ', 8 - (linelen % 8));
145 result[linelen + 8 - (linelen % 8)] = '\0'; 147 result[linelen + 8 - (linelen % 8)] = '\0';