summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/string.c b/string.c
index 7c49b34630..b06c2f5b8f 100644
--- a/string.c
+++ b/string.c
@@ -3025,7 +3025,8 @@ rb_str_inspect(VALUE str)
p += n;
if (c == '"'|| c == '\\' ||
- (c == '#' && (cc = rb_enc_codepoint(p,pend,enc),
+ (c == '#' && p < pend &&
+ (cc = rb_enc_codepoint(p,pend,enc),
(cc == '$' || cc == '@' || cc == '{')))) {
prefix_escape(result, c, enc);
}