From 1094eb7a1c368c3292c5a88d9a23014fb7d0b7f1 Mon Sep 17 00:00:00 2001 From: mischievous Date: Tue, 27 Apr 2021 13:34:58 -0500 Subject: [PATCH] Updated the class_copyMethodList (#206) Updated the class_copyMethodList to clear the stack garbage for outCount if preset before checking the class is null --- runtime.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/runtime.c b/runtime.c index b297f43a..be03c3f7 100644 --- a/runtime.c +++ b/runtime.c @@ -208,6 +208,11 @@ BOOL class_addProtocol(Class cls, Protocol *protocol) Ivar * class_copyIvarList(Class cls, unsigned int *outCount) { + if (outCount != NULL) + { + *outCount = 0x0; + } + CHECK_ARG(cls); struct objc_ivar_list *ivarlist = NULL; unsigned int count = 0; @@ -244,6 +249,11 @@ Ivar * class_copyIvarList(Class cls, unsigned int *outCount) Method * class_copyMethodList(Class cls, unsigned int *outCount) { + if (outCount != NULL) + { + *outCount = 0x0; + } + CHECK_ARG(cls); unsigned int count = 0; Method *list; @@ -256,10 +266,12 @@ Method * class_copyMethodList(Class cls, unsigned int *outCount) count += methods->count; } } + if (outCount != NULL) { *outCount = count; } + if (count == 0) { return NULL; @@ -282,6 +294,11 @@ Method * class_copyMethodList(Class cls, unsigned int *outCount) Protocol*__unsafe_unretained* class_copyProtocolList(Class cls, unsigned int *outCount) { + if (outCount != NULL) + { + *outCount = 0x0; + } + CHECK_ARG(cls); struct objc_protocol_list *protocolList = NULL; struct objc_protocol_list *list;