[PATCH libinput] Fix to avoid use of undefined pointer values.
Peter Hutterer
peter.hutterer at who-t.net
Thu May 28 18:02:39 PDT 2015
On Thu, May 28, 2015 at 05:13:14PM -0700, Jon A. Cruz wrote:
> If asprintf fails for any reason, the contents of the pointer
> are undefined. While some platforms set it to NULL, there is no
> guarantee that all will.
>
> Signed-off-by: Jon A. Cruz <jonc at osg.samsung.com>
> ---
> tools/libinput-list-devices.c | 59 ++++++++++++++++++++++++-------------------
> 1 file changed, 33 insertions(+), 26 deletions(-)
>
> diff --git a/tools/libinput-list-devices.c b/tools/libinput-list-devices.c
> index 6625173..b492e1d 100644
> --- a/tools/libinput-list-devices.c
> +++ b/tools/libinput-list-devices.c
> @@ -120,24 +120,27 @@ calibration_default(struct libinput_device *device)
> float calibration[6];
>
> if (!libinput_device_config_calibration_has_matrix(device)) {
> - asprintf(&str, "n/a");
> + if (asprintf(&str, "n/a") == -1)
> + str = NULL;
can we wrap that into an xasprintf() helper? that's a lot easier than
doing the == -1 dance.
Cheers,
Peter
More information about the wayland-devel
mailing list