better cope with null selectors.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31178 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2010-08-17 18:36:46 +00:00
parent 658003a847
commit fbbfb632c8
4 changed files with 21 additions and 6 deletions

View file

@ -1,3 +1,9 @@
2010-08-17 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSObject.m:
* Source/NSDistantObject.m:
Return nil from (methodSignatureForSelector:) if the selector is null.
2010-08-17 Wolfgang Lux <wolfgang.lux@gmail.com> 2010-08-17 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSNotificationQueue.m: remove_from_queue_no_release() * Source/NSNotificationQueue.m: remove_from_queue_no_release()

View file

@ -669,6 +669,10 @@ enum proxyLocation
*/ */
- (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector - (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector
{ {
if (0 == aSelector)
{
return nil;
}
if (_object != nil) if (_object != nil)
{ {
return [_object methodSignatureForSelector: aSelector]; return [_object methodSignatureForSelector: aSelector];

View file

@ -1461,7 +1461,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak));
/** /**
* Returns the method signature describing how the receiver would handle * Returns the method signature describing how the receiver would handle
* a message with aSelector. * a message with aSelector.
* <br />Raises NSInvalidArgumentException if given a null selector. * <br />Returns nil if given a null selector.
*/ */
- (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector - (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector
{ {
@ -1469,9 +1469,10 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak));
struct objc_method *mth; struct objc_method *mth;
Class c; Class c;
if (aSelector == 0) if (0 == aSelector)
[NSException raise: NSInvalidArgumentException {
format: @"%@ null selector given", NSStringFromSelector(_cmd)]; return nil;
}
c = (GSObjCIsInstance(self) ? object_getClass(self) : (Class)self); c = (GSObjCIsInstance(self) ? object_getClass(self) : (Class)self);
mth = GSGetMethod(c, aSelector, GSObjCIsInstance(self), YES); mth = GSGetMethod(c, aSelector, GSObjCIsInstance(self), YES);
@ -2395,6 +2396,10 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak));
{ {
Class c; Class c;
if (0 == aSelector)
{
return nil;
}
[allocationLock lock]; [allocationLock lock];
c = NSMapGet(zombieMap, (void*)self); c = NSMapGet(zombieMap, (void*)self);
[allocationLock unlock]; [allocationLock unlock];

View file

@ -147,7 +147,7 @@ extern BOOL __objc_responds_to(id, SEL);
{ {
struct objc_method *mth; struct objc_method *mth;
if (aSelector == 0) if (0 == aSelector)
{ {
return nil; return nil;
} }
@ -393,7 +393,7 @@ extern BOOL __objc_responds_to(id, SEL);
{ {
struct objc_method *mth; struct objc_method *mth;
if (aSelector == 0) if (0 == aSelector)
{ {
return nil; return nil;
} }