iliaa           Mon May 10 18:13:39 2004 EDT

  Modified files:              (Branch: PHP_4_3)
    /php-src    NEWS 
    /php-src/ext/cpdf   cpdf.c 
  Log:
  MFH: Fixed crash inside cpdf_place_inline_image() when working with
  truecolor images.
  
  
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1247.2.657&r2=1.1247.2.658&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1247.2.657 php-src/NEWS:1.1247.2.658
--- php-src/NEWS:1.1247.2.657   Sun May  9 22:12:17 2004
+++ php-src/NEWS        Mon May 10 18:13:38 2004
@@ -4,6 +4,8 @@
 - Upgraded bundled GD library to 2.0.23. (Ilia)
 - Fixed possible crash inside pg_copy_(to|from) function if delimiter is more
   then 1 character long. (Ilia)
+- Fixed crash inside cpdf_place_inline_image() when working with truecolor
+  images. (Ilia)
 - Fixed handling of return values from storred procedures in mssql_execute()
   with multiple result sets returned. (Frank)
 - Fixed logic bug in session_register() which allowed registering _SESSION
http://cvs.php.net/diff.php/php-src/ext/cpdf/cpdf.c?r1=1.43.4.5&r2=1.43.4.6&ty=u
Index: php-src/ext/cpdf/cpdf.c
diff -u php-src/ext/cpdf/cpdf.c:1.43.4.5 php-src/ext/cpdf/cpdf.c:1.43.4.6
--- php-src/ext/cpdf/cpdf.c:1.43.4.5    Wed Feb 18 21:20:14 2004
+++ php-src/ext/cpdf/cpdf.c     Mon May 10 18:13:39 2004
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: cpdf.c,v 1.43.4.5 2004/02/19 02:20:14 iliaa Exp $ */
+/* $Id: cpdf.c,v 1.43.4.6 2004/05/10 22:13:39 iliaa Exp $ */
 /* cpdflib.h -- C language API definitions for ClibPDF library
  * Copyright (C) 1998 FastIO Systems, All Rights Reserved.
 */
@@ -2522,16 +2522,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

Reply via email to