Skip to content

Commit 257054e

Browse files
committed
Fix bug #62922
Off by one error...
1 parent c7f4c5a commit 257054e

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

NEWS

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ PHP NEWS
3030

3131
- mysqlnd:
3232
. Fixed Bug #69796 (mysqli_stmt::fetch doesn't assign null values to
33-
bound variables). (Laruence);
33+
bound variables). (Laruence)
3434

3535
- Curl:
3636
. Fixed bug #69831 (Segmentation fault in curl_getinfo). (im dot denisenko at
@@ -48,6 +48,10 @@ PHP NEWS
4848
- SPL
4949
. Fixed bug #69845 (ArrayObject with ARRAY_AS_PROPS broken). (Dmitry)
5050

51+
- Standard
52+
. Fixed bug #62922 (Truncating entire string should result in string).
53+
(Nikita)
54+
5155
11 Jun 2015, PHP 7.0.0 Alpha 1
5256

5357
- Core:

ext/standard/string.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2406,7 +2406,7 @@ PHP_FUNCTION(substr)
24062406
}
24072407
}
24082408

2409-
if (f >= (zend_long)str->len) {
2409+
if (f > (zend_long)str->len) {
24102410
RETURN_FALSE;
24112411
}
24122412

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Bug #62922: Truncating entire string should result in string
3+
--FILE--
4+
<?php
5+
var_dump(substr("", 0));
6+
var_dump(substr("a", 1));
7+
var_dump(substr("ab", 2));
8+
?>
9+
--EXPECT--
10+
string(0) ""
11+
string(0) ""
12+
string(0) ""
12 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)