com php-src: Improve strtr (Fixed a bug which the lenth check doesn't work at all): ext/standard/string.c

From: Date: Fri, 19 Jun 2015 14:59:31 +0000
Subject: com php-src: Improve strtr (Fixed a bug which the lenth check doesn't work at all): ext/standard/string.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-87392@lists.php.net to get a copy of this message
Commit: a7635e82f6ab1c33ee91846b6fc1bc6f8b8739b6 Author: Xinchen Hui <laruence@php.net> Fri, 19 Jun 2015 22:59:31 +0800 Parents: cff872eaadfca6dd35ec6c07527fefd2b5bf613b Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a7635e82f6ab1c33ee91846b6fc1bc6f8b8739b6 Log: Improve strtr (Fixed a bug which the lenth check doesn't work at all) Changed paths: M ext/standard/string.c Diff: diff --git a/ext/standard/string.c b/ext/standard/string.c index c11dae6..5617a2c 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -3072,22 +3072,23 @@ static void php_strtr_array(zval *return_value, zend_string *input, HashTable *p old_pos = pos = 0; while (pos <= slen - minlen) { key = str + pos; - if (bitset[((unsigned char)key[0]) / sizeof(zend_ulong)] & Z_UL(1) << (((unsigned char)key[0]) % sizeof(zend_ulong))) { + if (bitset[((unsigned char)key[0]) / sizeof(zend_ulong)] & (Z_UL(1) << (((unsigned char)key[0]) % sizeof(zend_ulong)))) { len = maxlen; if (len > slen - pos) { len = slen - pos; } while (len >= minlen) { - if (num_bitset[len / sizeof(zend_ulong)] & Z_UL(1) << (len % sizeof(zend_ulong)) == 0) continue; - entry = zend_hash_str_find(pats, key, len); - if (entry != NULL) { - zend_string *s = zval_get_string(entry); - smart_str_appendl(&result, str + old_pos, pos - old_pos); - smart_str_append(&result, s); - old_pos = pos + len; - pos = old_pos - 1; - zend_string_release(s); - break; + if ((num_bitset[len / sizeof(zend_ulong)] & (Z_UL(1) << (len % sizeof(zend_ulong))))) { + entry = zend_hash_str_find(pats, key, len); + if (entry != NULL) { + zend_string *s = zval_get_string(entry); + smart_str_appendl(&result, str + old_pos, pos - old_pos); + smart_str_append(&result, s); + old_pos = pos + len; + pos = old_pos - 1; + zend_string_release(s); + break; + } } len--; }

« previous php.cvs (#87392) next »