Date: Tue, 3 Aug 2004 16:31:19 +0200 To: Christophe Pourbaix , 263239 at bugs.debian.org, lablgtk@kaba.or.jp Subject: Re: Bug#263239: liblablgtk2-ocaml-dev: GdkPixbuf.from_data fails with Invalid_argument Message-ID: <20040803143119.GC14871 at pegasos> Reply-To: 263239 at bugs.debian.org References: <200408031323.ATD04770 at mirapoint5.brutele.be> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <200408031323.ATD04770 at mirapoint5.brutele.be> From: Sven Luther tags 263239 upstream thanks On Tue, Aug 03, 2004 at 03:23:47PM +0200, Christophe Pourbaix wrote: > Package: liblablgtk2-ocaml-dev > Version: 2.4.0-1 > Severity: normal > Tags: patch > > from_data in gdkPixbuf.ml raises an Invalid_argument exception because > the size of the passed pixels buffer is smaller than > (rowstride * (height - 1) + width) * bytes_per_pixel). That comparison > is incorrect because rowstride is already multiplied with the depth. Ok. Jacques and other lablgtk upstreams, what do you think of this patch ? > Transcript: > > $ cat > foo.ml < let p = GdkPixbuf.from_file "some_file.png" in > let width = GdkPixbuf.get_width p in > let height = GdkPixbuf.get_height p in > let pixels = GdkPixbuf.get_pixels in > let p' = GdkPixbuf.from_data ~width ~height pixels in > GdkPixbuf.save "foo.png" "png" p';; > EOF > $ lablgtk2 foo.ml > Exception: Invalid_argument "GdkPixbuf.from_data". > > Fix (apply with -p0 in src): > > --- gdkPixbuf.ml 2004-03-24 01:49:00.000000000 +0100 > +++ gdkPixbuf-patch.ml 2004-08-03 15:06:30.000000000 +0200 > @@ -67,7 +67,9 @@ > let nc = if has_alpha then 4 else 3 in > let rowstride = match rowstride with None -> width * nc | Some r -> r in > if bits <> 8 || rowstride < width * nc || width <= 0 || height <= 0 > - || Gpointer.length data < (rowstride * (height - 1) + width) * nc > + (* rowstride is already width (+ pitch) * bytes_per_pixel *) > + (*|| Gpointer.length data < (rowstride * (height - 1) + width) * nc*) > + || Gpointer.length data < (rowstride * (height - 1) + width) > then invalid_arg "GdkPixbuf.from_data"; > _from_data data ~has_alpha ~bits ~width ~height ~rowstride Friendly, Sven Luther