GNOME Bugzilla – Bug 604001
SGI: Calculating amount of memory to allocate may overflow.
Last modified: 2009-12-09 16:21:07 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.
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.
Review of attachment 149273 [details] [review]: committed: 838be62 SGI: cast allocation calculations