GNOME Bugzilla – Bug 779136
save-pixbuf: Bits per channel is not the same as bytes per pixel
Last modified: 2017-02-26 12:13:42 UTC
We should the bytes per pixel to allocate the memory buffer, not bits per pixel. It doesn't cause a real problem at the moment, other than wasting memory.
Created attachment 346576 [details] [review] operations/external/save-pixbuf: Don't waste memory
Created attachment 346577 [details] [review] operations/external/save-pixbuf: Simplify the stride calculation
Created attachment 346578 [details] [review] operations/external/save-pixbuf: Try to avoid integer overflow
Thank you - patches applied - even the last one that - at least on 64bit systems, almost seem like overkill. ------ commit 923ae874551e5777bec253c945b8667d691614bc Author: Debarshi Ray <debarshir@gnome.org> Date: Thu Feb 23 15:43:37 2017 +0100 operations/external/save-pixbuf: Try to avoid integer overflow g_malloc0_n is safer than g_malloc0 since it detects any possible overflow during multiplication. https://bugzilla.gnome.org/show_bug.cgi?id=779136 commit 7a7b728f89c32c2e792457795780813c44dc5ab7 Author: Debarshi Ray <debarshir@gnome.org> Date: Thu Feb 23 15:39:40 2017 +0100 operations/external/save-pixbuf: Simplify the stride calculation ... and use the same value to read the GeglBuffer as the one passed to GdkPixbuf. This should avoid any inadvertent mismatches. https://bugzilla.gnome.org/show_bug.cgi?id=779136 commit 9153be299f1c6cc6ee545ef1dad428fe1ced018e Author: Debarshi Ray <debarshir@gnome.org> Date: Thu Feb 23 15:35:23 2017 +0100 operations/external/save-pixbuf: Don't waste memory A GdkPixbuf takes 8 bits per channel, but only 3 or 4 bytes per pixel. The later value should be used to allocate the buffer. https://bugzilla.gnome.org/show_bug.cgi?id=779136