From cbdac2f031888fb1cf5fcbabb80c180c3c547adb Mon Sep 17 00:00:00 2001 From: Haldun Bayhantopcu Date: Fri, 17 Nov 2023 16:22:09 +0100 Subject: [PATCH] [ruby/prism] Silence clang analyzer warnings for the memory leaks https://github.com/ruby/prism/commit/68112c556e --- prism/prism.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/prism/prism.c b/prism/prism.c index 3df36b0d2e..f1b7088ecd 100644 --- a/prism/prism.c +++ b/prism/prism.c @@ -10445,6 +10445,8 @@ parse_write_name(pm_parser_t *parser, pm_constant_id_t *name_field) { name[length] = '='; // Now switch the name to the new string. + // This silences clang analyzer warning about leak of memory pointed by `name`. + // NOLINTNEXTLINE(clang-analyzer-*) *name_field = pm_constant_pool_insert_owned(&parser->constant_pool, name, length + 1); } @@ -15707,6 +15709,9 @@ parse_regular_expression_named_captures(pm_parser_t *parser, const pm_string_t * if (memory == NULL) abort(); memcpy(memory, source, length); + + // This silences clang analyzer warning about leak of memory pointed by `memory`. + // NOLINTNEXTLINE(clang-analyzer-*) local = pm_parser_local_add_owned(parser, (const uint8_t *) memory, length); if (token_is_numbered_parameter(source, source + length)) {