diff options
Diffstat (limited to 'tapset/string.stp')
-rw-r--r-- | tapset/string.stp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/tapset/string.stp b/tapset/string.stp index 15791134..2f43aecc 100644 --- a/tapset/string.stp +++ b/tapset/string.stp @@ -20,10 +20,8 @@ function strlen:long(s:string) %{ /* pure */ * @return Returns the substring. */ function substr:string(str:string,start:long, length:long) %{ /* pure */ - int length = THIS->length + 1 > MAXSTRINGLEN ? MAXSTRINGLEN : THIS->length + 1; - if (THIS->start < 0 || length < 1) { - return; - } else + int length = THIS->length >= MAXSTRINGLEN ? MAXSTRINGLEN : THIS->length + 1; + if (THIS->start >= 0 && length > 0 && THIS->start < strlen(THIS->str)) strlcpy(THIS->__retvalue, THIS->str + THIS->start, length); %} |