php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48635 wrong variable assignment breaks strict compiler on NetWare
Submitted: 2009-06-22 01:31 UTC Modified: 2009-06-23 00:54 UTC
From: guenter@php.net Assigned: kalle (profile)
Status: Closed Package: GD related
PHP Version: 5.2.10 OS: all affected
Private report: No CVE-ID: None
 [2009-06-22 01:31 UTC] guenter@php.net
Description:
------------
I've just compiled PHP 5.2.10, and my strict NetWare compiler breaks in libgd/gd.c:
libgd\gd.c:3881: illegal implicit conversion from 'int' to
libgd\gd.c:3881: 'struct gdImageStruct *'
libgd\gd.c:3882: illegal implicit conversion from 'struct gdImageStruct *' to
libgd\gd.c:3882: 'int'

when I look at the code it seems to me that the compiler is right, and this commit:
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.90.2.1.2.24&r2=1.90.2.1.2.25
looks plain wrong for me: the prototype of gdImageColorAllocateAlpha() is:
int gdImageColorAllocateAlpha (gdImagePtr im, int r, int g, int b, int a)

and at all other places where gdImageColorAllocateAlpha() is used its return value is correctly assigned an int, and not a gdImagePtr.

suggested patch which makes it compile again:

--- gd.c.orig	Thu Apr 23 18:28:39 2009
+++ gd.c	Mon Jun 22 03:25:53 2009
@@ -3864,7 +3864,7 @@
 	int         x, y, i, j, new_a;
 	float       new_r, new_g, new_b;
 	int         new_pxl, pxl=0;
-	gdImagePtr  srcback, srctrans;
+	gdImagePtr  srcback;
 	typedef int (*FuncPtr)(gdImagePtr, int, int);
 	FuncPtr f;
 
@@ -3878,8 +3878,8 @@
 		return 0;
 	}
 	srcback->saveAlphaFlag = 1;
-	srctrans = gdImageColorAllocateAlpha(srcback, 0, 0, 0, 127);
-	gdImageFill(srcback, 0, 0, srctrans);
+	new_pxl = gdImageColorAllocateAlpha(srcback, 0, 0, 0, 127);
+	gdImageFill(srcback, 0, 0, new_pxl);
 
 	gdImageCopy(srcback, src,0,0,0,0,src->sx,src->sy);
 



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-22 12:17 UTC] guenter@php.net
just found that exactly same patch I suggested was already applied to 5.3 branch, but not backported to 5.2:
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.90.2.1.2.21.2.8&r2=1.90.2.1.2.21.2.9
 [2009-06-23 00:54 UTC] kalle@php.net
Pierre told me to backport it to 5.2, so closing this :)
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Jul 06 08:05:45 2022 UTC