From 6afb152122f242d39c886bffa02c55d764e20fe8 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 29 Jan 2019 22:00:40 +0000 Subject: [PATCH] Print NULL strings as "nil" in wl_closure_print Calling printf("%s", NULL) is undefined behaviour. Signed-off-by: Simon Ser Reviewed-by: Pekka Paalanen --- src/connection.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/connection.c b/src/connection.c index f9652107..474c97b5 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1278,7 +1278,10 @@ wl_closure_print(struct wl_closure *closure, struct wl_object *target, int send) wl_fixed_to_double(closure->args[i].f)); break; case 's': - fprintf(stderr, "\"%s\"", closure->args[i].s); + if (closure->args[i].s) + fprintf(stderr, "\"%s\"", closure->args[i].s); + else + fprintf(stderr, "nil"); break; case 'o': if (closure->args[i].o)