ncurses 6.2 - patch 20201017
[ncurses.git] / ncurses / trace / varargs.c
index 99e4f7659a7714dc6fb2f2a33d982991bc47c783..9be5fc254fb0e1bc6c1f30b86f35fb74e587dbc2 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2001-2008,2012 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2001-2008,2012 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -34,7 +35,7 @@
 
 #include <ctype.h>
 
-MODULE_ID("$Id: varargs.c,v 1.10 2012/02/22 22:40:24 tom Exp $")
+MODULE_ID("$Id: varargs.c,v 1.12 2020/02/02 23:34:34 tom Exp $")
 
 #ifdef TRACE
 
@@ -170,9 +171,11 @@ _nc_varargs(const char *fmt, va_list ap)
                        }
                        MyLength += strlen(param) + 2;
                        MyBuffer = typeRealloc(char, MyLength, MyBuffer);
-                       _nc_SPRINTF(MyBuffer + strlen(MyBuffer),
-                                   _nc_SLIMIT(MyLength - strlen(MyBuffer))
-                                   ", %s", param);
+                       if (MyBuffer != 0) {
+                           _nc_SPRINTF(MyBuffer + strlen(MyBuffer),
+                                       _nc_SLIMIT(MyLength - strlen(MyBuffer))
+                                       ", %s", param);
+                       }
                    }
                }
                used = atUnknown;
@@ -182,7 +185,7 @@ _nc_varargs(const char *fmt, va_list ap)
        }
     }
 
-    return (MyBuffer);
+    return (MyBuffer ? MyBuffer : dummy);
 }
 #else
 EMPTY_MODULE(_nc_varargs)