From: Arnaud Giersch Date: Tue, 17 Jan 2012 14:02:05 +0000 (+0100) Subject: Don't crash with NULL procname. X-Git-Tag: exp_20120216~125^2~5 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/1eac1757ad2fe043df17ac10262648504c226907 Don't crash with NULL procname. --- diff --git a/src/xbt/xbt_log_layout_format.c b/src/xbt/xbt_log_layout_format.c index d09a2fe417..9fe811b881 100644 --- a/src/xbt/xbt_log_layout_format.c +++ b/src/xbt/xbt_log_layout_format.c @@ -64,7 +64,11 @@ static double format_begin_of_time = -1; check_overflow(len); \ } else (void)0 -#define show_string(data) show_it(data, "s") +#define show_string(data) \ + if (1) { \ + const char *show_string_data = (data); \ + show_it(show_string_data ? show_string_data : "(null)", "s"); \ + } else (void)0 #define show_int(data) show_it(data, "d") #define show_double(data) show_it(data, "f") diff --git a/src/xbt/xbt_log_layout_simple.c b/src/xbt/xbt_log_layout_simple.c index 30108d4697..7a81a9c30c 100644 --- a/src/xbt/xbt_log_layout_simple.c +++ b/src/xbt/xbt_log_layout_simple.c @@ -40,7 +40,7 @@ static int xbt_log_layout_simple_doit(xbt_log_layout_t l, /* Display the proc info if available */ procname = xbt_procname(); - if (*procname) { + if (procname && *procname) { len = snprintf(p, rem_size, "%s:%s:(%d) ", gras_os_myname(), procname, xbt_getpid()); check_overflow(len);