Skip to content
Snippets Groups Projects
Commit 0158699a authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Don't return -1 from safe_snprintf() when size is zero.

parent 110f23bf
No related branches found
No related tags found
1 merge request!488Overhaul LZH code
Pipeline #7547 passed
......@@ -61,8 +61,12 @@ int safe_snprintf(char *dst, size_t size, const char *fmt, ...)
if(numchars==-1)
numchars=strlen(dst);
#endif
if ((size_t)numchars >= size && numchars > 0)
numchars = size - 1;
if ((size_t)numchars >= size && numchars > 0) {
if (size == 0)
numchars = 0;
else
numchars = size - 1;
}
return(numchars);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment