comparison th_string.c @ 248:3a2a29f801ed

Add check for NULL strings.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 16 Feb 2016 18:21:54 +0200
parents 2fc282c365a8
children 35cfda75606b
comparison
equal deleted inserted replaced
247:2fc282c365a8 248:3a2a29f801ed
193 193
194 static int th_vput_str(void *ctx, int (*vputch)(void *ctx, const char ch), 194 static int th_vput_str(void *ctx, int (*vputch)(void *ctx, const char ch),
195 const char *str, const char padMode, const char padChar, 195 const char *str, const char padMode, const char padChar,
196 const int width, const int prec) 196 const int width, const int prec)
197 { 197 {
198 int nwidth = width - strlen(str); 198 int nwidth, ret = 0;
199 int ret = 0; 199
200 // Check for null strings
201 if (str == NULL)
202 str = "(null)";
203
204 nwidth = width - strlen(str);
200 205
201 // Prefix padding? 206 // Prefix padding?
202 if (padMode != '-' && nwidth > 0) 207 if (padMode != '-' && nwidth > 0)
203 { 208 {
204 while (nwidth--) 209 while (nwidth--)