From c9c5f575ca5200d28ab77829c6c33c7fbad0e84e Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Mon, 12 Oct 2026 09:23:31 +0200 Subject: [PATCH] Initialize `filepath` option to the empty string Same as `current_string`, set it to be empty. Similarly, when populating user-provided options, we need to check the lengh, same as for `encoding`. Closes https://github.com/ruby/prism/issues/4249 --- src/prism.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/prism.c b/src/prism.c index d436fbd609..9bf07856cb 100644 --- a/src/prism.c +++ b/src/prism.c @@ -22992,7 +22992,7 @@ pm_parser_init(pm_arena_t *arena, pm_parser_t *parser, const uint8_t *source, si .encoding_changed_callback = NULL, .encoding_comment_start = source, .lex_callback = { 0 }, - .filepath = { 0 }, + .filepath = PM_STRING_EMPTY, .constant_pool = { 0 }, .line_offsets = { 0 }, .integer = { 0 }, @@ -23040,7 +23040,9 @@ pm_parser_init(pm_arena_t *arena, pm_parser_t *parser, const uint8_t *source, si // If options were provided to this parse, establish them here. if (options != NULL) { // filepath option - parser->filepath = options->filepath; + if (pm_string_length(&options->filepath) > 0) { + parser->filepath = options->filepath; + } // line option parser->start_line = options->line;