[Spice-devel] [PATCH 3/3] Fix "NULL_RETURNS" caught by coverity

Fabiano Fidêncio fabiano at fidencio.org
Mon Jul 14 04:21:34 PDT 2014


Hi Marc,


On Mon, Jul 14, 2014 at 12:19 PM, Marc-André Lureau <mlureau at redhat.com>
wrote:

> Hi,
>
> All of those changes are OOM conditions. How can we shut coverity on those?
>

Yes, there is a simple way and that's what we have in Evolution Data Server.
Long story short, we can just add some comments in the code like: /*
coverity[unchecked_value] */
Please, take a look on:
https://git.gnome.org/browse/evolution-data-server/commit/?id=a317be96dcffe6ce2c5900fe4e76d955e2294ce9

Can I go for it?

Why does it warn here and not for other allocations?
>

Hmmm. I don't know, maybe these are the cases where we are using the
members of the structure right after the allocation fail, but it's just a
guess.



> ----- 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
> >
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>



-- 
Fabiano Fidêncio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20140714/552fa378/attachment.html>


More information about the Spice-devel mailing list