From 06217cd05e4143598cc7ab93f5b9b2eb3627109f Mon Sep 17 00:00:00 2001 From: NOT XVilka Date: Sat, 20 Jun 2026 17:32:06 +0800 Subject: [PATCH] librz/type: fix forward type for enums (#6539) Co-authored-by: Anton Kochkov --- librz/type/parser/types_parser.c | 7 ++++++- test/db/cmd/types | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/librz/type/parser/types_parser.c b/librz/type/parser/types_parser.c index 2114fc4b14..8a5e2a21ba 100644 --- a/librz/type/parser/types_parser.c +++ b/librz/type/parser/types_parser.c @@ -210,7 +210,7 @@ int parse_sole_type_name(CParserState *state, TSNode node, const char *text, Par free(real_type); return 0; } - // Before resorting to create a new forward type, check if there is some union or struct with the same name already. + // Before resorting to create a new forward type, check if there is some union, struct or enum with the same name already. // This will e.g. catch cases like referring to `struct MyStruct` by just `MyStruct`. if ((*tpair = c_parser_get_structure_type(state, real_type))) { parser_debug(state, "Fetched type as struct: \"%s\"\n", real_type); @@ -222,6 +222,11 @@ int parse_sole_type_name(CParserState *state, TSNode node, const char *text, Par free(real_type); return 0; } + if ((*tpair = c_parser_get_enum_type(state, real_type))) { + parser_debug(state, "Fetched type as enum: \"%s\"\n", real_type); + free(real_type); + return 0; + } // If not - we form both RzType and RzBaseType to store in the Types database // as a forward-looking definition *tpair = c_parser_new_primitive_type(state, real_type, is_const); diff --git a/test/db/cmd/types b/test/db/cmd/types index 3e72c1a223..9c0f8c668e 100644 --- a/test/db/cmd/types +++ b/test/db/cmd/types @@ -2381,6 +2381,19 @@ fcn.00014d50 EOF RUN +NAME=tx on enum type +FILE=bins/elf/ioli/crackme0x00 +CMDS=<