Skip to content

Commit

Permalink
fix negative zend_long to size_t cast
Browse files Browse the repository at this point in the history
  • Loading branch information
weltling committed Jun 29, 2015
1 parent 8271890 commit 5060060
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ext/standard/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -2484,9 +2484,10 @@ PHP_FUNCTION(substr_replace)
* of the string
*/
if (f < 0) {
f = Z_STRLEN_P(str) + f;
if (f < 0) {
if (f < 0 && -f > Z_STRLEN_P(str)) {
f = 0;
} else {
f = Z_STRLEN_P(str) + f;
}
} else if (f > Z_STRLEN_P(str)) {
f = Z_STRLEN_P(str);
Expand Down

0 comments on commit 5060060

Please sign in to comment.