Skip to content

Commit

Permalink
Updated the class_copyMethodList (gnustep#206)
Browse files Browse the repository at this point in the history
Updated the class_copyMethodList to clear the stack garbage for outCount if preset before checking the class is null
  • Loading branch information
mischievous authored Apr 27, 2021
1 parent 921e3c3 commit 1094eb7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 1094eb7

Please sign in to comment.