Check snprintf for -1

This commit is contained in:
Nils O. Selåsdal
2015-11-25 09:40:21 +01:00
parent 6a2ecdf2f4
commit 9416c58457
2 changed files with 6 additions and 2 deletions
+2 -2
View File
@@ -279,12 +279,12 @@ int uc_dstr_vsprintf(struct DStr *str, const char *restrict fmt, va_list ap_)
needed = vsnprintf(str->str + str->len, available, fmt, ap);
va_end(ap);
if (needed <= 0) {
if (needed < 0) {
return needed;
}
if (needed >= available) {
rc = uc_dstr_ensure(str, str->len + needed);
rc = uc_dstr_ensure(str, str->len + needed + 1);
if (rc != 0) {
return -1;
}