mirror of
https://github.com/ruby/ruby.git
synced 2025-09-19 02:23:59 +02:00
merge revision(s) f748b911c9
: [Backport #17729]
Fix infinite loop at illegal sequence [Bug #17729] As mblen returns -1 on failure, skip the first byte and try the succeeding bytes in that case. Close https://github.com/ruby/ruby/pull/4281 --- eval_intern.h | 11 ++++++++++- test/ruby/test_rubyoptions.rb | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-)
This commit is contained in:
parent
d1cec0bca5
commit
1a47de64f4
3 changed files with 16 additions and 2 deletions
|
@ -302,7 +302,16 @@ VALUE rb_ec_backtrace_location_ary(const rb_execution_context_t *ec, long lev, l
|
|||
|
||||
#ifndef CharNext /* defined as CharNext[AW] on Windows. */
|
||||
# ifdef HAVE_MBLEN
|
||||
# define CharNext(p) ((p) + mblen((p), RUBY_MBCHAR_MAXSIZE))
|
||||
# define CharNext(p) rb_char_next(p)
|
||||
static inline const char *
|
||||
rb_char_next(const char *p)
|
||||
{
|
||||
if (p) {
|
||||
int len = mblen(p, RUBY_MBCHAR_MAXSIZE);
|
||||
p += len > 0 ? len : 1;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
# else
|
||||
# define CharNext(p) ((p) + 1)
|
||||
# endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue