diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-13 10:35:06 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-13 10:35:06 +0000 |
| commit | 814bc25b4c8107cdf221df11abf0f57bd8169848 (patch) | |
| tree | 6527875daf250b9be0671acb2d7f359c5a888e08 | |
| parent | c319ce5ec6fbc8eb1912fc5b9fe34489b11fcec9 (diff) | |
| download | ruby-814bc25b4c8107cdf221df11abf0f57bd8169848.tar.gz ruby-814bc25b4c8107cdf221df11abf0f57bd8169848.tar.xz ruby-814bc25b4c8107cdf221df11abf0f57bd8169848.zip | |
* string.c (sym_printable): wrong condition for string iteration.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@20724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | string.c | 7 |
2 files changed, 7 insertions, 4 deletions
@@ -1,3 +1,7 @@ +Sat Dec 13 18:34:43 2008 Yukihiro Matsumoto <matz@ruby-lang.org> + + * string.c (sym_printable): wrong condition for string iteration. + Sat Dec 13 16:04:48 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp> * encoding.c (default_external): endless recursion during @@ -6827,10 +6827,9 @@ sym_equal(VALUE sym1, VALUE sym2) static int -sym_printable(const char *s, rb_encoding *enc) +sym_printable(const char *s, const char *send, rb_encoding *enc) { - const char *send = s + strlen(s); - while (s) { + while (s < send) { int c = rb_enc_codepoint(s, send, enc); int n = rb_enc_codelen(c, enc); if (!rb_enc_isprint(c, enc)) return Qfalse; @@ -6862,7 +6861,7 @@ sym_inspect(VALUE sym) memcpy(RSTRING_PTR(str)+1, RSTRING_PTR(sym), RSTRING_LEN(sym)); if (RSTRING_LEN(sym) != strlen(RSTRING_PTR(sym)) || !rb_enc_symname_p(RSTRING_PTR(sym), enc) || - !sym_printable(RSTRING_PTR(sym), enc)) { + !sym_printable(RSTRING_PTR(sym), RSTRING_END(sym), enc)) { str = rb_str_inspect(str); strncpy(RSTRING_PTR(str), ":\"", 2); } |
