From: Ben Pfaff Date: Mon, 17 Apr 2006 03:36:40 +0000 (+0000) Subject: Make ds_vprintf() properly handle a null string. X-Git-Tag: v0.6.0~973 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a621b4a73d06d73a753c9f7207c03393dfb1b81e;p=pspp-builds.git Make ds_vprintf() properly handle a null string. --- diff --git a/src/libpspp/ChangeLog b/src/libpspp/ChangeLog index ff8d321e..2c80db58 100644 --- a/src/libpspp/ChangeLog +++ b/src/libpspp/ChangeLog @@ -1,3 +1,8 @@ +Sun Apr 16 20:33:19 2006 Ben Pfaff + + * str.c (ds_vprintf): Don't try to write into the string if it is + null. + Sun Apr 16 18:52:41 2006 Ben Pfaff GNU standards require "file name" instead of "filename" in diff --git a/src/libpspp/str.c b/src/libpspp/str.c index c72f1996..c8497c34 100644 --- a/src/libpspp/str.c +++ b/src/libpspp/str.c @@ -704,7 +704,7 @@ ds_vprintf (struct string *st, const char *format, va_list args_) #endif va_copy (args, args_); - avail = st->capacity - st->length + 1; + avail = st->string != NULL ? st->capacity - st->length + 1 : 0; needed = vsnprintf (st->string + st->length, avail, format, args); va_end (args);