mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
fix dereferencing null pointer
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32543 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a9b73e8804
commit
2ce7b39e04
1 changed files with 47 additions and 19 deletions
|
@ -722,8 +722,14 @@ method_getName(Method method)
|
|||
unsigned
|
||||
method_getNumberOfArguments(Method method)
|
||||
{
|
||||
const char *types = method->method_types;
|
||||
if (0 == method)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int count = 0;
|
||||
const char *types = method->method_types;
|
||||
|
||||
while ('\0' != *types)
|
||||
{
|
||||
|
@ -732,9 +738,19 @@ method_getNumberOfArguments(Method method)
|
|||
}
|
||||
return count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
method_getReturnType(Method method, char *dst, size_t dst_len)
|
||||
{
|
||||
if (0 == method)
|
||||
{
|
||||
if (dst_len > 0)
|
||||
{
|
||||
dst[0] = '\0';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO: Coped and pasted code. Factor it out.
|
||||
const char *types = method->method_types;
|
||||
|
@ -745,20 +761,31 @@ method_getReturnType(Method method, char *dst, size_t dst_len)
|
|||
memcpy(dst, types, length);
|
||||
dst[length] = '\0';
|
||||
}
|
||||
else
|
||||
else if (dst_len > 0)
|
||||
{
|
||||
memcpy(dst, types, dst_len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char *
|
||||
method_getTypeEncoding(Method method)
|
||||
{
|
||||
if (0 == method)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return method->method_types;
|
||||
}
|
||||
|
||||
IMP
|
||||
method_setImplementation(Method method, IMP imp)
|
||||
{
|
||||
if (0 == method)
|
||||
{
|
||||
return (IMP)0;
|
||||
}
|
||||
else
|
||||
{
|
||||
IMP old = (IMP) method->method_imp;
|
||||
|
||||
|
@ -766,6 +793,7 @@ method_setImplementation(Method method, IMP imp)
|
|||
objc_updateDtableForClassContainingMethod(method);
|
||||
return old;
|
||||
}
|
||||
}
|
||||
|
||||
id
|
||||
objc_getClass(const char *name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue