fix unnecessary printf retry when printed string is empty

Tue, 16 Jan 2024 23:16:15 +0100

author
Mike Becker <universe@uap-core.de>
date
Tue, 16 Jan 2024 23:16:15 +0100
changeset 812
fda0f1910d7e
parent 811
b02ad05c7f2d
child 813
aba6d37b78bd

fix unnecessary printf retry when printed string is empty

src/printf.c file | annotate | diff | comparison | revisions
--- a/src/printf.c	Tue Jan 16 23:15:36 2024 +0100
+++ b/src/printf.c	Tue Jan 16 23:16:15 2024 +0100
@@ -108,7 +108,7 @@
     va_list ap2;
     va_copy(ap2, ap);
     int ret = vsnprintf(buf, CX_PRINTF_SBO_SIZE, fmt, ap);
-    if (ret > 0 && ret < CX_PRINTF_SBO_SIZE) {
+    if (ret >= 0 && ret < CX_PRINTF_SBO_SIZE) {
         s.ptr = cxMalloc(a, ret + 1);
         if (s.ptr) {
             s.length = (size_t) ret;

mercurial