vsprintf returns int not char*

php.internals

Kamesh Jayachandran

21 years ago
Hi Derick, in php-src/main/php_sprintf.c PHPAPI int php_sprintf (char*s, const char* format, ...) { va_list args; char *ret; //ret should be of type integer as vsprintf returns int rather than char* va_start (args, format); s[0] = '\0'; ret = vsprintf (s, format, args); va_end (args); if (!ret) //This check should be if(ret < 0) as ret will have the number of characters printed to s //If an output error is encountered, a negative value is returned. return -1; return strlen (s); } ret should be of type integer as vsprintf returns int rather than char*. if (!ret) should be if(ret < 0) With regards Kamesh Jayachandran

Derick Rethans

21 years ago
On Tue, 4 Jan 2005, Kamesh Jayachandran wrote:
> Hi Derick, > in php-src/main/php_sprintf.c > PHPAPI int > php_sprintf (char*s, const char* format, ...) > { > va_list args; > char *ret; //ret should be of type integer as vsprintf returns int rather than char*
It is already an int, please update your source trees. Derick
-- Derick Rethans http://derickrethans.nl | http://ez.no | http://xdebug.org

Kamesh Jayachandran

21 years ago
Hi Derick, Sorry I have seen this PHP-5.0.3 bundle. The change is there on December 17 commit on PHP5_0. Still I feel this should be replaced if (!ret) return -1; by if (ret<0) return -1; As the document for vsprintf states as follows, If an output error is encountered, a negative value is returned. With regards Kamesh Jayachandran On Tue, 4 Jan 2005 14:44:56 +0100 (CET), "Derick Rethans" <derick@php.net> said: