From 1b7a492ab281a19871efab690169cb08edc5b1cf Mon Sep 17 00:00:00 2001 From: theraven Date: Mon, 14 Jan 2013 18:13:48 +0000 Subject: [PATCH] Fix a small memory leak of selector names when registering selectors with the same name but different types. --- selector_table.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/selector_table.c b/selector_table.c index c2629cf..ec932ff 100644 --- a/selector_table.c +++ b/selector_table.c @@ -354,7 +354,19 @@ static SEL objc_register_selector_copy(SEL aSel, BOOL copyArgs) } // Create a copy of this selector. copy = selector_pool_alloc(); - copy->name = copyArgs ? strdup(aSel->name) : aSel->name; + copy->name = aSel->name; + if (copyArgs) + { + SEL untyped = selector_lookup(aSel->name, 0); + if (untyped != NULL) + { + copy->name = sel_getName(untyped); + } + else + { + copy->name = strdup(aSel->name); + } + } copy->types = (NULL == aSel->types) ? NULL : (copyArgs ? strdup(aSel->types) : aSel->types); // Try to register the copy as the authoritative version