Index: src/OFExceptions.m ================================================================== --- src/OFExceptions.m +++ src/OFExceptions.m @@ -12,10 +12,11 @@ #import "config.h" #define _GNU_SOURCE #import #import +#import #import #import "OFExceptions.h" @@ -67,13 +68,18 @@ } - initWithObject: (id)obj andSize: (size_t)size { - if ((self = [super init])) - asprintf(&errstr, "ERROR: Could not allocate %zu bytes for " - "object of class %s!\n", size, [obj name]); + if ((self = [super init])) { + if (obj != nil) + asprintf(&errstr, "ERROR: Could not allocate %zu bytes " + "for object of class %s!\n", size, [obj name]); + else + asprintf(&errstr, "ERROR: Could not allocate %zu bytes " + "for object of class (null)!\n", size); + } return self; } @end @@ -125,13 +131,18 @@ return [[OFOverflowException alloc] initWithObject: obj]; } - initWithObject: (id)obj { - if ((self = [super init])) - asprintf(&errstr, "ERROR: Overflow in object of class %s!\n", - [obj name]); + if ((self = [super init])) { + if (obj != nil) + asprintf(&errstr, "ERROR: Overflow in object of class " + "%s!\n", [obj name]); + else + errstr = strdup("ERROR: Overflow in object of class " + "(null)!\n"); + } return self; } @end