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 604001 - SGI: Calculating amount of memory to allocate may overflow.
SGI: Calculating amount of memory to allocate may overflow.
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Plugins
git master
Other Linux
: Normal major
: ---
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2009-12-07 17:02 UTC by Nils Philippsen
Modified: 2009-12-09 16:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed fix: cast allocation calculations (1.77 KB, patch)
2009-12-07 17:02 UTC, Nils Philippsen
committed Details | Review

Description Nils Philippsen 2009-12-07 17:02:26 UTC
Created attachment 149273 [details] [review]
Proposed fix: cast allocation calculations

When calculating how much memory it should allocate for certain operations, the
SGI plugin does it like "g_new (gushort, sgip->xsize * sgip->zsize)".

Since it's not explicitly cast, the calculation is done with the type of the
sgip->xsize variable which may overflow the calculation (since both xsize and
zsize are unsigned short ints). Casting the first variable of such calculations to gsize causes the whole calculation to be done in that type, avoiding an overflowed result.
Comment 1 Simon Budig 2009-12-09 14:43:23 UTC
Review of attachment 149273 [details] [review]:

Cosmetic issues: put a space between the cast and the variable.

This makes the code a bit better to read.

Otherwise good, please commit.
Comment 2 Nils Philippsen 2009-12-09 16:20:50 UTC
Review of attachment 149273 [details] [review]:

committed:
838be62 SGI: cast allocation calculations