[PATCH] Print NULL strings as "nil" in wl_closure_print
Simon Ser
contact at emersion.fr
Tue Jan 29 22:00:40 UTC 2019
Calling printf("%s", NULL) is undefined behaviour.
Signed-off-by: Simon Ser <contact at emersion.fr>
---
src/connection.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/connection.c b/src/connection.c
index f965210..474c97b 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)
--
2.20.1
More information about the wayland-devel
mailing list