diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2019-02-10 00:36:34 +0100 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2019-02-10 14:16:46 +0100 |
commit | 90518bfc8415adccc7d89bc7b57723be7b5e488b (patch) | |
tree | f8ef515f68d74fabd392b2f1678fc33c3710e390 /Process.c | |
parent | f49f5458131f4492795600e629622197500ec05f (diff) |
Return of snprintf is not the number of written bytes
Diffstat (limited to 'Process.c')
-rw-r--r-- | Process.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -414,11 +414,16 @@ void Process_writeField(Process* this, RichString* str, ProcessField field) { if (indent & (1U << i)) maxIndent = i+1; for (int i = 0; i < maxIndent - 1; i++) { - int written; + int written, ret; if (indent & (1 << i)) - written = snprintf(buf, n, "%s ", CRT_treeStr[TREE_STR_VERT]); + ret = snprintf(buf, n, "%s ", CRT_treeStr[TREE_STR_VERT]); else - written = snprintf(buf, n, " "); + ret = snprintf(buf, n, " "); + if (ret < 0 || ret >= n) { + written = n; + } else { + written = ret; + } buf += written; n -= written; } |