[PATCH 1/3] Use zalloc rather than malloc and manually setting members to 0
Marek Chalupa
mchqwerty at gmail.com
Fri Dec 5 04:52:44 PST 2014
Hi,
On 26 November 2014 at 22:49, Bryce Harrington <bryce at osg.samsung.com>
wrote:
> On Wed, Nov 26, 2014 at 03:33:16PM +0100, Marek Chalupa wrote:
> > On 21 November 2014 at 07:21, Bryce Harrington <bryce at osg.samsung.com>
> > wrote:
> >
> > > Signed-off-by: Bryce Harrington <bryce at osg.samsung.com>
> > >
> > > - if (do_yflip)
> > > - recorder->tmpbuf = NULL;
> > > - else
> > > + if (!do_yflip)
> > > recorder->tmpbuf = malloc(size);
> > >
> >
> > Here you don't check the malloc's result.
>
> Good point. The original code didn't either, but
> weston_recorder_frame_notify() looks like it assumes tmpbuf is valid and
> would crash there otherwise. I can add this.
>
I found out that I have add this check when I was testing your patches, so
I sent it to list.
I hope you don't mind that I took you the 'work' here :)
>
> > Also in weston_recorder_destroy
> > there's no check that tmpbuf was allocated before freeing that memory.
>
> Actually it's unnecessary to check for NULL before calling free().
> free(NULL) is a no-op as per `man 3 malloc`.
>
> Thanks for the review!
>
> Bryce
>
>
Thanks,
Marek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20141205/daed51d2/attachment-0001.html>
More information about the wayland-devel
mailing list