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

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

parent 6e92fde6
No related branches found
No related tags found
No related merge requests found
......@@ -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.
Please register or to comment