File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -2177,7 +2177,7 @@ PHP_FUNCTION(substr)
2177
2177
/* if "from" position is negative, count start position from the end
2178
2178
* of the string
2179
2179
*/
2180
- if ((size_t )- f > ZSTR_LEN (str )) {
2180
+ if (- (size_t )f > ZSTR_LEN (str )) {
2181
2181
f = 0 ;
2182
2182
} else {
2183
2183
f = (zend_long )ZSTR_LEN (str ) + f ;
@@ -2191,7 +2191,7 @@ PHP_FUNCTION(substr)
2191
2191
/* if "length" position is negative, set it to the length
2192
2192
* needed to stop that many chars from the end of the string
2193
2193
*/
2194
- if ((size_t )( - l ) > ZSTR_LEN (str ) - (size_t )f ) {
2194
+ if (- (size_t )l > ZSTR_LEN (str ) - (size_t )f ) {
2195
2195
l = 0 ;
2196
2196
} else {
2197
2197
l = (zend_long )ZSTR_LEN (str ) - f + l ;
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ substr() with PHP_INT_MIN offset or length
3
+ --FILE--
4
+ <?php
5
+ var_dump (substr ('x ' , PHP_INT_MIN ));
6
+ var_dump (substr ('x ' , 0 , PHP_INT_MIN ));
7
+ ?>
8
+ --EXPECT--
9
+ string(1) "x"
10
+ string(0) ""
You can’t perform that action at this time.
0 commit comments