[Spice-devel] [PATCH 3/3] Fix "NULL_RETURNS" caught by coverity
Marc-André Lureau
mlureau at redhat.com
Mon Jul 14 03:19:39 PDT 2014
Hi,
All of those changes are OOM conditions. How can we shut coverity on those?
Why does it warn here and not for other allocations?
----- Original Message -----
> ---
> gtk/controller/test.c | 3 +++
> gtk/spice-client-gtk.override | 3 +++
> gtk/spice-widget.c | 2 ++
> 3 files changed, 8 insertions(+)
>
> diff --git a/gtk/controller/test.c b/gtk/controller/test.c
> index 851f237..5a9c8b9 100644
> --- a/gtk/controller/test.c
> +++ b/gtk/controller/test.c
> @@ -96,6 +96,9 @@ void send_data (uint32_t id, uint8_t* data, size_t
> data_size)
> size_t size = sizeof (ControllerData) + data_size;
> ControllerData* msg = (ControllerData*)malloc (size);
>
> + if (msg == NULL)
> + return;
> +
> msg->base.id = id;
> msg->base.size = (uint32_t)size;
> memcpy (msg->data, data, data_size);
> diff --git a/gtk/spice-client-gtk.override b/gtk/spice-client-gtk.override
> index 31e4f9e..76c5d8b 100644
> --- a/gtk/spice-client-gtk.override
> +++ b/gtk/spice-client-gtk.override
> @@ -40,6 +40,9 @@ _wrap_spice_display_send_keys(PyGObject *self,
>
> len = PyList_Size(keyList);
> keys = malloc(sizeof(guint)*len);
> + if (keys == NULL)
> + return NULL;
> +
> for (i = 0 ; i < len ; i++) {
> PyObject *val;
> char *sym;
> diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
> index 9b835f0..f43321a 100644
> --- a/gtk/spice-widget.c
> +++ b/gtk/spice-widget.c
> @@ -2560,6 +2560,8 @@ GdkPixbuf *spice_display_get_pixbuf(SpiceDisplay
> *display)
> g_return_val_if_fail(d->data != NULL, NULL);
>
> data = g_malloc(d->area.width * d->area.height * 3);
> + g_return_val_if_fail (data != NULL, NULL);
> +
> src = d->data;
> dest = data;
>
> --
> 1.9.3
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>
More information about the Spice-devel
mailing list