#9386 Fix function delete failing when 2 or more tags are applied

This commit is contained in:
brothersw
2026-07-22 13:54:54 -04:00
committed by dragonmacher
parent ad8f879a86
commit 7ccc6e852b
2 changed files with 30 additions and 1 deletions
@@ -115,6 +115,35 @@ public class DeleteFunctionCmdTest extends AbstractGenericTest {
program.endTransaction(transactionID, false);
}
/*
* This is a regression test. Make sure function deletes work with multiple tags.
* See issue #9386.
*/
@Test
public void testDeleteFunctionWithMultipleTags() {
Address address = addr(0x0);
String defaultName = SymbolUtilities.getDefaultFunctionName(address);
int transactionID = program.startTransaction("TEST");
Function function =
createFunction(defaultName, address, new AddressSet(address, address.add(200L)));
assertNotNull("The test function was not created as expected.", function);
function.addTag("tag1");
function.addTag("tag2");
function.addTag("tag3");
DeleteFunctionCmd deleteFunctionCmd = new DeleteFunctionCmd(address);
deleteFunctionCmd.applyTo(program);
function = program.getListing().getFunctionAt(address);
assertNull("The function was not deleted as expected.", function);
program.endTransaction(transactionID, false);
}
// looks through the given symbol array to see if any have the same name
// as the provided string
private boolean containsMatchingSymbolName(Symbol[] symbols, String name) {
@@ -430,7 +430,7 @@ public class FunctionManagerDB implements FunctionManager {
}
// Remove all tag mappings associated with this function
for (FunctionTag tag : function.getTags()) {
for (FunctionTag tag : new ArrayList<>(function.getTags())) {
function.removeTag(tag.getName());
}