After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 779136 - save-pixbuf: Bits per channel is not the same as bytes per pixel
save-pixbuf: Bits per channel is not the same as bytes per pixel
Status: RESOLVED FIXED
Product: GEGL
Classification: Other
Component: operations
git master
Other All
: Normal normal
: ---
Assigned To: Default Gegl Component Owner
Default Gegl Component Owner
Depends on:
Blocks:
 
 
Reported: 2017-02-23 14:33 UTC by Debarshi Ray
Modified: 2017-02-26 12:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
operations/external/save-pixbuf: Don't waste memory (1.39 KB, patch)
2017-02-23 14:44 UTC, Debarshi Ray
none Details | Review
operations/external/save-pixbuf: Simplify the stride calculation (1.79 KB, patch)
2017-02-23 14:44 UTC, Debarshi Ray
none Details | Review
operations/external/save-pixbuf: Try to avoid integer overflow (1.04 KB, patch)
2017-02-23 14:44 UTC, Debarshi Ray
none Details | Review

Description Debarshi Ray 2017-02-23 14:33:05 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.
Comment 1 Debarshi Ray 2017-02-23 14:44:07 UTC
Created attachment 346576 [details] [review]
operations/external/save-pixbuf: Don't waste memory
Comment 2 Debarshi Ray 2017-02-23 14:44:23 UTC
Created attachment 346577 [details] [review]
operations/external/save-pixbuf: Simplify the stride calculation
Comment 3 Debarshi Ray 2017-02-23 14:44:42 UTC
Created attachment 346578 [details] [review]
operations/external/save-pixbuf: Try to avoid integer overflow
Comment 4 Øyvind Kolås (pippin) 2017-02-26 12:13:42 UTC
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