Skip to content

Commit 7534bf1

Browse files
committed
fix set_time_limit, substr and some more
1 parent 1169de3 commit 7534bf1

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

ext/standard/array.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4432,7 +4432,7 @@ PHP_FUNCTION(array_map)
44324432
RETVAL_NULL();
44334433

44344434
if (n_arrays == 1) {
4435-
ulong num_key;
4435+
php_uint_t num_key;
44364436
zend_string *str_key;
44374437
zval *zv;
44384438

ext/standard/html.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,7 @@ PHPAPI zend_string *php_escape_html_entities_ex(unsigned char *old, size_t oldle
14431443
static void php_html_entities(INTERNAL_FUNCTION_PARAMETERS, int all)
14441444
{
14451445
zend_string *str, *hint_charset = NULL;
1446+
char *default_charset;
14461447
php_int_t flags = ENT_COMPAT;
14471448
zend_string *replaced;
14481449
zend_bool double_encode = 1;
@@ -1462,9 +1463,9 @@ static void php_html_entities(INTERNAL_FUNCTION_PARAMETERS, int all)
14621463
#endif
14631464

14641465
if (!hint_charset) {
1465-
hint_charset = get_default_charset(TSRMLS_C);
1466+
default_charset = get_default_charset(TSRMLS_C);
14661467
}
1467-
replaced = php_escape_html_entities_ex((unsigned char*)str->val, str->len, all, (int) flags, (hint_charset ? hint_charset->val : NULL), double_encode TSRMLS_CC);
1468+
replaced = php_escape_html_entities_ex((unsigned char*)str->val, str->len, all, (int) flags, (hint_charset ? hint_charset->val : default_charset), double_encode TSRMLS_CC);
14681469
RETVAL_STR(replaced);
14691470
}
14701471
/* }}} */
@@ -1525,6 +1526,7 @@ PHP_FUNCTION(htmlspecialchars_decode)
15251526
PHP_FUNCTION(html_entity_decode)
15261527
{
15271528
zend_string *str, *hint_charset = NULL;
1529+
char *default_charset;
15281530
size_t new_len = 0;
15291531
php_int_t quote_style = ENT_COMPAT;
15301532
zend_string *replaced;
@@ -1544,9 +1546,9 @@ PHP_FUNCTION(html_entity_decode)
15441546
#endif
15451547

15461548
if (!hint_charset) {
1547-
hint_charset = get_default_charset(TSRMLS_C);
1549+
default_charset = get_default_charset(TSRMLS_C);
15481550
}
1549-
replaced = php_unescape_html_entities((unsigned char*)str->val, str->len, 1 /*all*/, quote_style, hint_charset->val TSRMLS_CC);
1551+
replaced = php_unescape_html_entities((unsigned char*)str->val, str->len, 1 /*all*/, quote_style, (hint_charset ? hint_charset->val : default_charset) TSRMLS_CC);
15501552

15511553
if (replaced) {
15521554
RETURN_STR(replaced);

ext/standard/string.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,10 @@ PHP_FUNCTION(hex2bin)
283283
static void php_spn_common_handler(INTERNAL_FUNCTION_PARAMETERS, int behavior) /* {{{ */
284284
{
285285
char *s11, *s22;
286-
int len1, len2;
286+
php_int_t len1, len2;
287287
php_int_t start = 0, len = 0;
288288

289-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|ll", &s11, &len1,
289+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|ii", &s11, &len1,
290290
&s22, &len2, &start, &len) == FAILURE) {
291291
return;
292292
}
@@ -2252,28 +2252,28 @@ PHP_FUNCTION(substr)
22522252
if (argc > 2) {
22532253
if ((l < 0 && -l > str->len)) {
22542254
RETURN_FALSE;
2255-
} else if (l > str->len) {
2255+
} else if (l > (php_int_t)str->len) {
22562256
l = str->len;
22572257
}
22582258
} else {
22592259
l = str->len;
22602260
}
22612261

2262-
if (f > str->len) {
2262+
if (f > (php_int_t)str->len) {
22632263
RETURN_FALSE;
22642264
} else if (f < 0 && -f > str->len) {
22652265
f = 0;
22662266
}
22672267

2268-
if (l < 0 && (l + str->len - f) < 0) {
2268+
if (l < 0 && (l + (php_int_t)str->len - f) < 0) {
22692269
RETURN_FALSE;
22702270
}
22712271

22722272
/* if "from" position is negative, count start position from the end
22732273
* of the string
22742274
*/
22752275
if (f < 0) {
2276-
f = str->len + f;
2276+
f = (php_int_t)str->len + f;
22772277
if (f < 0) {
22782278
f = 0;
22792279
}
@@ -2283,17 +2283,17 @@ PHP_FUNCTION(substr)
22832283
* needed to stop that many chars from the end of the string
22842284
*/
22852285
if (l < 0) {
2286-
l = (str->len - f) + l;
2286+
l = ((php_int_t)str->len - f) + l;
22872287
if (l < 0) {
22882288
l = 0;
22892289
}
22902290
}
22912291

2292-
if (f >= str->len) {
2292+
if (f >= (php_int_t)str->len) {
22932293
RETURN_FALSE;
22942294
}
22952295

2296-
if ((f + l) > str->len) {
2296+
if ((f + l) > (php_int_t)str->len) {
22972297
l = str->len - f;
22982298
}
22992299

@@ -2418,7 +2418,7 @@ PHP_FUNCTION(substr_replace)
24182418
}
24192419
} else { /* str is array of strings */
24202420
zend_string *str_index = NULL;
2421-
ulong num_index;
2421+
php_uint_t num_index;
24222422
int result_len;
24232423

24242424
array_init(return_value);
@@ -2815,7 +2815,7 @@ static int php_strtr_key_compare(const void *a, const void *b TSRMLS_DC) /* {{{
28152815
/* {{{ php_strtr_array */
28162816
static void php_strtr_array(zval *return_value, char *str, int slen, HashTable *pats TSRMLS_DC)
28172817
{
2818-
ulong num_key;
2818+
php_uint_t num_key;
28192819
zend_string *str_key;
28202820
int len, pos, found;
28212821
int num_keys = 0;
@@ -3805,7 +3805,7 @@ static void php_str_replace_common(INTERNAL_FUNCTION_PARAMETERS, int case_sensit
38053805
zval *subject, *search, *replace, *subject_entry, *zcount = NULL;
38063806
zval result;
38073807
zend_string *string_key;
3808-
ulong num_key;
3808+
php_uint_t num_key;
38093809
int count = 0;
38103810
int argc = ZEND_NUM_ARGS();
38113811

main/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,7 @@ PHP_FUNCTION(set_time_limit)
13331333
int new_timeout_strlen;
13341334
zend_string *key;
13351335

1336-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &new_timeout) == FAILURE) {
1336+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &new_timeout) == FAILURE) {
13371337
return;
13381338
}
13391339

0 commit comments

Comments
 (0)