From 201972ac4cf81d12a7018308b9e88400c5e61a9d Mon Sep 17 00:00:00 2001 From: rhe Date: Wed, 14 Dec 2016 12:32:42 +0000 Subject: encoding.c: handle needmore error from rb_enc_precise_mbclen() rb_enc_ascget() erroneously reports success even if the given byte sequence is incomplete, for non-ASCII compatible encoding strings. rb_enc_precise_mbclen() may return a negative value on error, and thus rb_enc_ascget() must not store the return value in 'unsigned int'; otherwise the subsequent MBCLEN_CHARFOUND_P() check won't catch the error. [ruby-core:78646] [Bug #13034] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- encoding.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'encoding.c') diff --git a/encoding.c b/encoding.c index f5ec1e756d..68871db268 100644 --- a/encoding.c +++ b/encoding.c @@ -1031,7 +1031,8 @@ rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc) int rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc) { - unsigned int c, l; + unsigned int c; + int l; if (e <= p) return -1; if (rb_enc_asciicompat(enc)) { -- cgit v1.2.3