summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-17 23:41:44 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-17 23:41:44 +0000
commite43c0bde5323c9dcd27ba284c1bdc7f11fa313ac (patch)
tree300e11fda0bc457cf727dc41f00be554431fbb6b /string.c
parent932591003708aac785a1e71ed6beb83e91554320 (diff)
* string.c (str_utf8_nth): fixed overrun. [ruby-core:26787]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/string.c b/string.c
index 1cd5e7fbe4..f923b5f168 100644
--- a/string.c
+++ b/string.c
@@ -1483,6 +1483,7 @@ str_utf8_nth(const char *p, const char *e, long nth)
} while (s < t && (int)sizeof(VALUE) <= nth);
p = (char *)s;
}
+ if (p > e) return 0;
while (p < e) {
if (is_utf8_lead_byte(*p)) {
if (nth == 0) break;