summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-16 06:37:42 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-16 06:37:42 +0000
commit5b2b1130cf7beadedb7176e44b356f157f5a8838 (patch)
treeb9eb376355de0334f91dc78e160c75547b6e8cbc /string.c
parent5bae48bd566603d005543c1ad5130a6a286800a3 (diff)
string.c: fix checking order
* string.c (str_undump): check for suffix before if Unicode escape conflicts with it. the message "but used force_encoding" sounds strange when it is not used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/string.c b/string.c
index 25323ce313..a7948224e5 100644
--- a/string.c
+++ b/string.c
@@ -6289,15 +6289,15 @@ str_undump(VALUE str)
int encidx;
ptrdiff_t size;
- if (utf8) {
- rb_raise(rb_eRuntimeError, "dumped string contained Unicode escape but used force_encoding");
- }
-
size = rb_strlen_lit(".force_encoding(\"");
if (s_end - s <= size) goto invalid_format;
if (memcmp(s, ".force_encoding(\"", size) != 0) goto invalid_format;
s += size;
+ if (utf8) {
+ rb_raise(rb_eRuntimeError, "dumped string contained Unicode escape but used force_encoding");
+ }
+
encname = s;
s = memchr(s, '"', s_end-s);
size = s - encname;