cvs: gd /libgd/src gd_tiff.c

From: Date: Sat, 06 Oct 2007 10:52:09 +0000
Subject: cvs: gd /libgd/src gd_tiff.c
Groups: php.gd.cvs 
Request: Send a blank email to php-gd-cvs+get-301@lists.php.net to get a copy of this message
nlopess Sat Oct 6 10:52:09 2007 UTC Modified files: /gd/libgd/src gd_tiff.c Log: replace pow(2, ) with a bitwise shift add comment to note that no overflow check is necessary in the colorMap* allocations http://cvs.php.net/viewvc.cgi/gd/libgd/src/gd_tiff.c?r1=1.8&r2=1.9&diff_format=u Index: gd/libgd/src/gd_tiff.c diff -u gd/libgd/src/gd_tiff.c:1.8 gd/libgd/src/gd_tiff.c:1.9 --- gd/libgd/src/gd_tiff.c:1.8 Sat Oct 6 10:42:17 2007 +++ gd/libgd/src/gd_tiff.c Sat Oct 6 10:52:09 2007 @@ -29,7 +29,7 @@ ---------------------------------------------------------------------------- */ -/* $Id: gd_tiff.c,v 1.8 2007/10/06 10:42:17 nlopess Exp $ */ +/* $Id: gd_tiff.c,v 1.9 2007/10/06 10:52:09 nlopess Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -249,10 +249,10 @@ /* build the color map for 8 bit images */ if(bitDepth != 24) { - /*TODO: Add checking */ - colorMapRed = (uint16 *) gdMalloc(3 * pow(2, bitsPerSample)); - colorMapGreen = (uint16 *) gdMalloc(3 * pow(2, bitsPerSample)); - colorMapBlue = (uint16 *) gdMalloc(3 * pow(2, bitsPerSample)); + /* no overflow check is necessary because bitsPerSample is at most 8 and the following doesn't overflow */ + colorMapRed = (uint16 *) gdMalloc(3 * (1 << bitsPerSample)); + colorMapGreen = (uint16 *) gdMalloc(3 * (1 << bitsPerSample)); + colorMapBlue = (uint16 *) gdMalloc(3 * (1 << bitsPerSample)); for(i = 0; i < image->colorsTotal; i++) { colorMapRed[i] = gdImageRed(image,i) + (gdImageRed(image,i) * 256); @@ -409,7 +409,7 @@ uint32 offset; TIFFGetField(tiff, TIFFTAG_BITSPERSAMPLE, &bitsPerSample); - offset = pow(2, bitsPerSample); + offset = 1 << bitsPerSample; if(color == 0) { val = ctx.red[index];

« previous php.gd.cvs (#301) next »