diff options
| author | Rasmus Lerdorf <rasmus@php.net> | 1999-05-12 12:53:45 +0000 |
|---|---|---|
| committer | Rasmus Lerdorf <rasmus@php.net> | 1999-05-12 12:53:45 +0000 |
| commit | fbeeb8f29c09c9c434f82a845ed11806da024852 (patch) | |
| tree | d07a9ff06ca479fa28ba573d294bf8c0b295a22b | |
| parent | 43d93b653364415ca5d7f436e7e8a04753152f4d (diff) | |
| download | php-git-fbeeb8f29c09c9c434f82a845ed11806da024852.tar.gz | |
substr() fix
| -rw-r--r-- | ext/standard/string.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/standard/string.c b/ext/standard/string.c index 012de6a611..e1880c93b6 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -826,9 +826,10 @@ void php3_substr(INTERNAL_FUNCTION_PARAMETERS) RETURN_FALSE; } - if ((f + l) < (int)string->value.str.len) { - string->value.str.val[f + l] = '\0'; + if((f+l) > (int)string->value.str.len) { + l = (int)string->value.str.len - f; } + RETVAL_STRINGL(string->value.str.val + f, l, 1); } /* }}} */ |
