CLI segfault, in sapi_cli_single_write
| From: | Pierre-Alain Joye | Date: | Mon, 19 Jan 2004 20:41:28 +0000 |
| Subject: | CLI segfault, in sapi_cli_single_write | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-7191@lists.php.net to get a copy of this message | ||
Hello,
I got a segfault in sapi_cli_single_write. For an (yet) unknown reason,
str becomes empty. The attached patch fixes it.
sidenote: found it by trying to resolve huge segfault in dom_xpath_query
pierre
Index: sapi/cli/php_cli.c =================================================================== RCS file: /repository/php-src/sapi/cli/php_cli.c,v retrieving revision 1.107 diff -u -p -r1.107 php_cli.c --- sapi/cli/php_cli.c 14 Jan 2004 03:14:17 -0000 1.107 +++ sapi/cli/php_cli.c 19 Jan 2004 20:38:16 -0000 @@ -189,6 +189,10 @@ static inline size_t sapi_cli_single_wri #else size_t ret; + if (!str) { + return 0; + } + ret = fwrite(str, 1, MIN(str_length, 16384), stdout); return ret; #endif
Index: sapi/cli/php_cli.c =================================================================== RCS file: /repository/php-src/sapi/cli/php_cli.c,v retrieving revision 1.107 diff -u -p -r1.107 php_cli.c --- sapi/cli/php_cli.c 14 Jan 2004 03:14:17 -0000 1.107 +++ sapi/cli/php_cli.c 19 Jan 2004 20:38:16 -0000 @@ -189,6 +189,10 @@ static inline size_t sapi_cli_single_wri #else size_t ret; + if (!str) { + return 0; + } + ret = fwrite(str, 1, MIN(str_length, 16384), stdout); return ret; #endif