|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-04-22 00:05 UTC] JClawson at tamu dot edu
Description:
------------
The my_free function macro in ext/xmlrpc/libxmlrpc/xml_element.c is poorly written and results in invalid C code on line 192. Please remove this macro completly from the file and write out the proper code for each case the free() function is called.
/home/upgrade-tmp/php5-STABLE-200504211236/ext/xmlrpc/libxmlrpc/xml_element.c: In function 'xml_elem_free_non_recurse':
/home/upgrade-tmp/php5-STABLE-200504211236/ext/xmlrpc/libxmlrpc/xml_element.c:192: error: invalid lvalue in assignment
/home/upgrade-tmp/php5-STABLE-200504211236/ext/xmlrpc/libxmlrpc/xml_element.c: In function 'xml_elem_entity_escape':
/home/upgrade-tmp/php5-STABLE-200504211236/ext/xmlrpc/libxmlrpc/xml_element.c:317: warning: pointer targets in assignment differ in signedness
/home/upgrade-tmp/php5-STABLE-200504211236/ext/xmlrpc/libxmlrpc/xml_element.c:332: warning: pointer targets in assignment differ in signedness
make: *** [ext/xmlrpc/libxmlrpc/xml_element.lo] Error 1
Reproduce code:
---------------
Here is the macro
#define my_free(thing) if(thing) {free(thing); thing = 0;}
This will not work on 192:
my_free((char*)root->name);
Expected result:
----------------
Consider changing the call on 192 from:
my_free((char*)root->name);
to:
if(root -> name)
{
free((char*)root->name);
root->name = 0;
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 21 23:00:01 2025 UTC |
Sorry... the code I posted should be this if (root->name) { free((char *)root->name); root->name = NULL; }Oh... Everyone will not be using GCC 3 forever. Don't you think it would be prudent to correct obvious errors now? After all if you have the following code: if((char*)root->name) { free((char*)root->name); (char*)root->name = 0; } why would you assign a pointer to 0? And for whatever reason... why the stupid if statement???? Why not just simplify everything with: free((char*)root->name); Bam... correct C code. If root->name is NULL thats ok... because free can take NULL as a paramater! You don't free somthing and then try to assign an integer to it... seriously.