GNOME Bugzilla – Bug 776945
tests: Fix possible infinite loops
Last modified: 2017-01-09 17:12:58 UTC
.
Created attachment 343021 [details] [review] tests: Fix possible infinite loops In the unlikely case that the just created pixbuf is invalid, the returned sizes would be negative. Ensure that those are positive and non-zero to avoid possible infinite loops. Coverity CID 1391987 Coverity CID 1391988
Review of attachment 343021 [details] [review]: > Ensure that those are positive and non-zero to avoid possible infinite loops. Anal nitpick: ‘positive’ includes non-zero. ‘Non-negative’ doesn’t. So you could just say ‘Ensure that those are positive to avoid…’. But looks good to push in any case. :-)
Review of attachment 343021 [details] [review]: ::: tests/pixbuf-scale.c @@ +257,3 @@ /* Check that the result is all gray (or all white in the case of NEAREST) */ for (y = 0, row = gdk_pixbuf_get_pixels (scaled); + y < scaled_height; Actually, don’t you want to cast `scaled_height` to `(guint)` here to avoid a warning about a signed/unsigned integer comparison? Similarly below.
(In reply to Philip Withnall from comment #3) > Review of attachment 343021 [details] [review] [review]: > > ::: tests/pixbuf-scale.c > @@ +257,3 @@ > /* Check that the result is all gray (or all white in the case of > NEAREST) */ > for (y = 0, row = gdk_pixbuf_get_pixels (scaled); > + y < scaled_height; > > Actually, don’t you want to cast `scaled_height` to `(guint)` here to avoid > a warning about a signed/unsigned integer comparison? > > Similarly below. I don't get any warnings about it, and I compiled with --enable-debug=yes
(In reply to Bastien Nocera from comment #4) > (In reply to Philip Withnall from comment #3) > > Review of attachment 343021 [details] [review] [review] [review]: > > > > ::: tests/pixbuf-scale.c > > @@ +257,3 @@ > > /* Check that the result is all gray (or all white in the case of > > NEAREST) */ > > for (y = 0, row = gdk_pixbuf_get_pixels (scaled); > > + y < scaled_height; > > > > Actually, don’t you want to cast `scaled_height` to `(guint)` here to avoid > > a warning about a signed/unsigned integer comparison? > > > > Similarly below. > > I don't get any warnings about it, and I compiled with --enable-debug=yes OK, looks like I don’t understand the C spec ottomh as well as I thought. Go for it, with or without the cast as you prefer. (I think it would make the code a bit clearer in any case, but I don’t really care.)
Created attachment 343173 [details] [review] tests: Fix possible infinite loops In the unlikely case that the just created pixbuf is invalid, the returned sizes would be negative. Ensure that those are positive to avoid possible infinite loops. Coverity CID 1391987 Coverity CID 1391988
Attachment 343173 [details] pushed as 0144147 - tests: Fix possible infinite loops