[PATCH] Print NULL strings as "nil" in wl_closure_print

Pekka Paalanen ppaalanen at gmail.com
Wed Jan 30 13:50:40 UTC 2019


On Tue, 29 Jan 2019 22:00:40 +0000
Simon Ser <contact at emersion.fr> wrote:

> 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)

Pushed:
   d325140..6afb152  master -> master


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20190130/b611149e/attachment.sig>


More information about the wayland-devel mailing list