Avoid Heap Overflow in `heredoc_remove_indent`; fix
MODIFY
mrbgems/mruby-compiler/core/parse.y
mrbgems/mruby-compiler/core/parse.y
@@ -4693,6 +4693,7 @@ heredoc_remove_indent(parser_state *p, parser_heredoc_info *hinf)
escaped = escaped->cdr;
nspaces = nspaces->cdr;
}
+ if (newlen < len)
newstr[newlen] = '\0';
pair->car = (node*)newstr;
pair->cdr = (node*)newlen;

MODIFY
mrbgems/mruby-compiler/core/y.tab.c
mrbgems/mruby-compiler/core/y.tab.c
@@ -10729,6 +10729,7 @@ heredoc_remove_indent(parser_state *p, parser_heredoc_info *hinf)
escaped = escaped->cdr;
nspaces = nspaces->cdr;
}
+ if (newlen < len)
newstr[newlen] = '\0';
pair->car = (node*)newstr;
pair->cdr = (node*)newlen;

Avoid Heap Overflow in `heredoc_remove_indent`; fix #5316