diff --git a/Mapping.c b/Mapping.c index e21b7de30d..3baf2f120a 100644 --- a/Mapping.c +++ b/Mapping.c @@ -181,6 +181,7 @@ void map_implicit_writes(MCInst *MI, const insn_map *imap) } /// Adds a given group to @MI->flat_insn. +/// A group is never added twice. void add_group(MCInst *MI, unsigned /* arch_group */ group) { #ifndef CAPSTONE_DIET @@ -192,6 +193,11 @@ void add_group(MCInst *MI, unsigned /* arch_group */ group) printf("ERROR: Too many groups defined.\n"); return; } + for (int i = 0; i < detail->groups_count; ++i) { + if (detail->groups[i] == group) { + return; + } + } detail->groups[detail->groups_count++] = group; #endif // CAPSTONE_DIET }