summaryrefslogtreecommitdiffstats
path: root/Process.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2019-02-10 00:36:34 +0100
committerHisham Muhammad <hisham@gobolinux.org>2019-02-10 14:16:46 +0100
commit90518bfc8415adccc7d89bc7b57723be7b5e488b (patch)
treef8ef515f68d74fabd392b2f1678fc33c3710e390 /Process.c
parentf49f5458131f4492795600e629622197500ec05f (diff)
Return of snprintf is not the number of written bytes
Diffstat (limited to 'Process.c')
-rw-r--r--Process.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/Process.c b/Process.c
index d6e30ee7..54c41af4 100644
--- a/Process.c
+++ b/Process.c
@@ -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;
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy