]> granicus.if.org Git - strace/blobdiff - vsprintf.c
Introduce XLAT macro to ease maintenance of xlat structures
[strace] / vsprintf.c
index b66609ac79beb5768421dcbdbdf301883ab1db0a..92fe1a7a622a210a8d0f4d7e6307e9e910762820 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "defs.h"
 
-#ifdef USE_CUSTOM_PRINTF
+#if USE_CUSTOM_PRINTF
 
 #include <stdarg.h>
 #include <limits.h>
@@ -759,8 +759,8 @@ int kernel_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
 
 int strace_vfprintf(FILE *fp, const char *fmt, va_list args)
 {
-       static char *buf;
-       static unsigned buflen;
+       static char *buf = NULL;
+       static unsigned buflen = 0;
 
        int r;
        va_list a1;
@@ -773,6 +773,8 @@ int strace_vfprintf(FILE *fp, const char *fmt, va_list args)
                buflen = len + 256;
                free(buf);
                buf = malloc(buflen);
+               if (!buf)
+                       die_out_of_memory();
                /*len =*/ kernel_vsnprintf(buf, buflen, fmt, args);
        }