Re: inline pixbufs
- From: Havoc Pennington <hp redhat com>
- To: Darin Adler <darin eazel com>
- Cc: <gtk-devel-list gnome org>
- Subject: Re: inline pixbufs
- Date: 26 Jul 2000 16:04:21 -0400
Darin Adler <darin@eazel.com> writes:
> > + if (length >= 0 &&
> > + length < (height * rowstride + 13)) {
> > + /* Not enough buffer to hold the remaining header
> > + * information plus the data.
> > + */
> > +
> > + return NULL;
> > + }
>
> Need to handle overflow here. If a garbled height or row stride is a very
> large value, then length might look good even though it is too short.
>
I'm thinking you mean height*rowstride overflows my int, if you don't
mean that then correct me.
> Could have a check here that has_alpha is consistent with n_channels. Does
> it work to have n_channels == 4 and has_alpha == false?
>
Well, the code works because n_channels gets ignored, but worth fixing
for clarity.
> One way to do it is:
>
> if (n_channels != (has_alpha ? 4 : 3))
> return NULL;
>
> Also, someone pedantic might suggest that you reject booleans that are
> anything other than 0 or 1, rather than treating all non-0 as 1, but that
> person would be way more pedantic than me :-)
>
gdk_pixbuf_new() should canonicalize the incoming bool anyway, if it
doesn't. GTK normally does this so we can use equality tests on bools.
Thanks!
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]