Make printf of gstring null-safe
authorJeremy Harris <jgh146exb@wizmail.org>
Fri, 11 Aug 2023 12:24:57 +0000 (13:24 +0100)
committerJeremy Harris <jgh146exb@wizmail.org>
Fri, 11 Aug 2023 12:24:57 +0000 (13:24 +0100)
Broken-by: 00392be0e7cf
src/src/string.c

index 854cf0d34b6e73915ada64173114067dbea601b8..52b1d2fb5895ccda12006d34d0b38d71049bbd34 100644 (file)
@@ -1579,8 +1579,8 @@ while (*fp)
     case 'Y':                  /* gstring pointer */
       {
       gstring * zg = va_arg(ap, gstring *);
-      s = CS zg->s;
-      slen = zg->ptr;
+      if (zg) { s = CS zg->s; slen = zg->ptr;    }
+      else    { s = null;     slen = Ustrlen(s); }
       goto INSERT_GSTRING;
       }