Date: 12/28/98
- Next message: zeev: "[PHP-DEV] CVS update: php3/functions"
- Previous message: Sascha Schumann: "Re: [PHP-DEV] CVS update: php3/functions"
- In reply to: Sascha Schumann: "Re: [PHP-DEV] CVS update: php3/functions"
- Next in thread: Sascha Schumann: "Re: [PHP-DEV] CVS update: php3/functions"
- Reply: Sascha Schumann: "Re: [PHP-DEV] CVS update: php3/functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At 21:11 28/12/98 +0100, Sascha Schumann wrote:
>On Mon, 28 Dec 1998, Zeev Suraski wrote:
>
>> Unless I'm missing something, I'm against this patch. The optimizations
>> seem to be trivial enough for any optimizing compiler to do them by itself;
>> The real problem is that it seems to change the behavior of the function
>> altogether (an empty element is returned for a NULL field, instead of that
>> element being unset).
>
>Yes, you are missing something :-)
>
>The old code was
>
> element = PQgetvalue(pgsql_result,row->value.lval,i);
> element_len = (element ? strlen(element) : 0);
> element = safe_estrndup(element,element_len);
>
>safe_estrndup is defined as
>
>#define safe_estrndup(ptr,len) \
> ((ptr)?(estrndup((ptr),(len))):(empty_string))
>
>So if PQgetvalue() returns NULL, safe_estrndup() will return empty_string
>which results in
>
>if(element) {
> /* always being executed */
>} else {
> /* something commented out */
>}
Ok, you did find a bug then, but the fix doesn't really fix anything.
There's no reason to duplicate empty_string, ever, it can be returned as-is
as it would never be freed by any part of the PHP engine.
Zeev
-- Zeev Suraski <zeev <email protected>> For a PGP public key, finger bourbon <email protected>-- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe <email protected> For help: php-dev-help <email protected>
- Next message: zeev: "[PHP-DEV] CVS update: php3/functions"
- Previous message: Sascha Schumann: "Re: [PHP-DEV] CVS update: php3/functions"
- In reply to: Sascha Schumann: "Re: [PHP-DEV] CVS update: php3/functions"
- Next in thread: Sascha Schumann: "Re: [PHP-DEV] CVS update: php3/functions"
- Reply: Sascha Schumann: "Re: [PHP-DEV] CVS update: php3/functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

