Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Commit

Permalink
Return of snprintf is not the number of written bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamhm committed Feb 10, 2019
1 parent f49f545 commit 90518bf
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Process.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 90518bf

Please sign in to comment.