summaryrefslogtreecommitdiff
path: root/yarp
diff options
context:
space:
mode:
authorMike Dalessio <mike.dalessio@gmail.com>2023-08-21 14:47:24 -0400
committergit <svn-admin@ruby-lang.org>2023-08-21 19:00:55 +0000
commit95e29b0423450447ea0adbf06564969f0e437673 (patch)
tree9f95e96642eab7091eeac2b16a305d42aff7ea9d /yarp
parent461f8eaba74a7475bf97921e3ed45b63b126a190 (diff)
[ruby/yarp] fix: avoid invalid memory read when CR is present without LF
https://github.com/ruby/yarp/commit/2296c037de
Diffstat (limited to 'yarp')
-rw-r--r--yarp/yarp.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/yarp/yarp.c b/yarp/yarp.c
index 65c9e959fd..3f250abfe4 100644
--- a/yarp/yarp.c
+++ b/yarp/yarp.c
@@ -6183,7 +6183,9 @@ parser_lex(yp_parser_t *parser) {
parser->current.end++;
}
- yp_newline_list_check_append(&parser->newline_list, parser->current.end);
+ if (peek(parser) == '\n') {
+ yp_newline_list_append(&parser->newline_list, parser->current.end);
+ }
parser->current.end++;
if (parser->current.end < parser->end) {
@@ -6191,7 +6193,7 @@ parser_lex(yp_parser_t *parser) {
}
}
- switch (*parser->current.end) {
+ switch (peek(parser)) {
case 'i': {
parser->current.end++;