php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #39962
Patch substr_insert.patch revision 2011-08-23 15:37 UTC by datibbaw@php.net
revision 2011-08-23 14:08 UTC by datibbaw@php.net
revision 2011-08-23 14:05 UTC by datibbaw@php.net

Patch substr_insert.patch for *General Issues Bug #39962

Patch version 2011-08-23 14:05 UTC

Return to Bug #39962 | Download this patch
This patch is obsolete

Obsoleted by patches:

Patch Revisions: 2011-08-23 15:37 UTC | 2011-08-23 14:08 UTC | 2011-08-23 14:05 UTC

Developer: datibbaw@php.net



  +
   /* {{{ proto string quotemeta(string str)
      Quotes meta characters */
   PHP_FUNCTION(quotemeta)
 @@ -5271,17 +5308,25 @@
  {
  	char *s1, *s2;
  	int s1_len, s2_len;
 -	long offset, len=0;
 +	long offset, len = 0;
  	zend_bool cs=0;
  	uint cmp_len;
 +	zval **zlen = NULL;
  
 -	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl|lb", &s1, &s1_len, &s2, &s2_len, &offset, &len, &cs) == FAILURE) {
 +	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl|Zb", &s1, &s1_len, &s2, &s2_len, &offset, &zlen, &cs) == FAILURE) {
  		RETURN_FALSE;
  	}
  
 -	if (ZEND_NUM_ARGS() >= 4 && len <= 0) {
 -		php_error_docref(NULL TSRMLS_CC, E_WARNING, "The length must be greater than zero");
 -		RETURN_FALSE;
 +	if (ZEND_NUM_ARGS() >= 4 && Z_TYPE_PP(zlen) != IS_NULL) {
 +		if (Z_ISREF_PP(zlen)) {
 +			SEPARATE_ZVAL(zlen);
 +		}
 +		convert_to_long_ex(zlen);
 +		len = Z_LVAL_PP(zlen);
 +		if (len <= 0) {
 +			php_error_docref(NULL TSRMLS_CC, E_WARNING, "The length must be greater than zero");
 +			RETURN_FALSE;
 +		}
  	}
  
  	if (offset < 0) {
  Index: basic_functions.c
  ===================================================================
  --- basic_functions.c	(revision 315071)
  +++ basic_functions.c	(working copy)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 18:01:28 2024 UTC