Fix bug in protocol_copyMethodDescriptionList() where we were calling calloc()

with a wrong element size.
main
thebeing 14 years ago
parent e7ab10611f
commit 1684283af0

@ -309,7 +309,7 @@ get_method_list(Protocol *p,
struct objc_method_description *protocol_copyMethodDescriptionList(Protocol *p, struct objc_method_description *protocol_copyMethodDescriptionList(Protocol *p,
BOOL isRequiredMethod, BOOL isInstanceMethod, unsigned int *count) BOOL isRequiredMethod, BOOL isInstanceMethod, unsigned int *count)
{ {
if (NULL == p) { return NULL; } if ((NULL == p) || (NULL == count)){ return NULL; }
struct objc_method_description_list *list = struct objc_method_description_list *list =
get_method_list(p, isRequiredMethod, isInstanceMethod); get_method_list(p, isRequiredMethod, isInstanceMethod);
*count = 0; *count = 0;
@ -317,9 +317,8 @@ struct objc_method_description *protocol_copyMethodDescriptionList(Protocol *p,
*count = list->count; *count = list->count;
struct objc_method_description *out = struct objc_method_description *out =
calloc(sizeof(struct objc_method_description_list), list->count); calloc(sizeof(struct objc_method_description), list->count);
for (int i=0 ; i < (list->count) ; i++)
for (int i=0 ; i<list->count ; i++)
{ {
out[i].name = sel_registerTypedName_np(list->methods[i].name, out[i].name = sel_registerTypedName_np(list->methods[i].name,
list->methods[i].types); list->methods[i].types);

Loading…
Cancel
Save