cvs: php4 /ext/standard string.c

From: Date: Sat, 01 Dec 2001 15:45:55 +0000
Subject: cvs: php4 /ext/standard string.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-8353@lists.php.net to get a copy of this message
derick Sat Dec 1 10:45:55 2001 EDT Modified files: /php4/ext/standard string.c Log: - Fix a crash when passing e.g. NULL to basename(). (Patch by Markus Fischer <mfischer@guru.josefine.at>) #- Simplyfied code using zend_parse_parameters(). Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.253 php4/ext/standard/string.c:1.254 --- php4/ext/standard/string.c:1.253 Sat Nov 10 18:44:04 2001 +++ php4/ext/standard/string.c Sat Dec 1 10:45:55 2001 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: string.c,v 1.253 2001/11/10 23:44:04 andrei Exp $ */ +/* $Id: string.c,v 1.254 2001/12/01 15:45:55 derick Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -1114,24 +1114,15 @@ Returns the filename component of the path */ PHP_FUNCTION(basename) { - zval **str, **suffix; char *ret; - char *suffixp = NULL; - int suffix_len = 0; - int argc = ZEND_NUM_ARGS(); + char *string, *suffix = NULL; + int string_len, suffix_len = 0; - if (argc < 1 || argc > 2 || - zend_get_parameters_ex(argc, &str, &suffix) == FAILURE) { - WRONG_PARAM_COUNT; - } - - if (argc > 1) { - convert_to_string_ex(suffix); - suffixp = Z_STRVAL_PP(suffix); - suffix_len = Z_STRLEN_PP(suffix); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &string, &string_len, &suffix, &suffix_len) == FAILURE) { + return; } - ret = php_basename(Z_STRVAL_PP(str), Z_STRLEN_PP(str), suffixp, suffix_len); + ret = php_basename(string, string_len, suffix, suffix_len); RETURN_STRING(ret, 0); } /* }}} */

« previous php.cvs (#8353) next »