iliaa Mon May 10 18:13:08 2004 EDT
Modified files:
/php-src/ext/cpdf cpdf.c
Log:
Fixed crash inside cpdf_place_inline_image() when working with truecolor
images.
http://cvs.php.net/diff.php/php-src/ext/cpdf/cpdf.c?r1=1.56&r2=1.57&ty=u
Index: php-src/ext/cpdf/cpdf.c
diff -u php-src/ext/cpdf/cpdf.c:1.56 php-src/ext/cpdf/cpdf.c:1.57
--- php-src/ext/cpdf/cpdf.c:1.56 Wed Feb 18 21:19:11 2004
+++ php-src/ext/cpdf/cpdf.c Mon May 10 18:13:08 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: cpdf.c,v 1.56 2004/02/19 02:19:11 iliaa Exp $ */
+/* $Id: cpdf.c,v 1.57 2004/05/10 22:13:08 iliaa Exp $ */
/* cpdflib.h -- C language API definitions for ClibPDF library
* Copyright (C) 1998 FastIO Systems, All Rights Reserved.
*/
@@ -2056,16 +2056,30 @@
}
count = 3 * im->sx * im->sy;
- if(NULL == (buffer = (unsigned char *) emalloc(count)))
- RETURN_FALSE;
+ buffer = (unsigned char *) safe_emalloc(3 * im->sx, im->sy, 0);
ptr = buffer;
for(i=0; i<im->sy; i++) {
for(j=0; j<im->sx; j++) {
- color = im->pixels[i][j];
- *ptr++ = im->red[color];
- *ptr++ = im->green[color];
- *ptr++ = im->blue[color];
+#if HAVE_LIBGD20
+ if(gdImageTrueColor(im)) {
+ if (im->tpixels && gdImageBoundsSafe(im, j, i)) {
+ color = gdImageTrueColorPixel(im, j, i);
+ *ptr++ = (color >> 16) & 0xFF;
+ *ptr++ = (color >> 8) & 0xFF;
+ *ptr++ = color & 0xFF;
+ }
+ } else {
+#endif
+ if (im->pixels && gdImageBoundsSafe(im, j, i)) {
+ color = im->pixels[i][j];
+ *ptr++ = im->red[color];
+ *ptr++ = im->green[color];
+ *ptr++ = im->blue[color];
+ }
+#if HAVE_LIBGD20
+ }
+#endif
}
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php