Fixed a crash on ticket load reported by Hannes Mannerhiem on the Growl discussion list.
authorPeter Hosey <hg@boredzo.org>
Tue Dec 01 08:46:18 2009 -0800 (2009-12-01)
changeset 456207b66c657951
parent 4561 2cbf094215a6
child 4563 4ac369b906c7
Fixed a crash on ticket load reported by Hannes Mannerhiem on the Growl discussion list.

Somehow, a ticket ended up in Mannerhiem's Tickets directory without an application name. Since Growl expected to find one, it crashed. We now log a message to the Console instead.
Core/Source/GrowlTicketController.m
     1.1 --- a/Core/Source/GrowlTicketController.m	Mon Nov 30 20:31:49 2009 -0800
     1.2 +++ b/Core/Source/GrowlTicketController.m	Tue Dec 01 08:46:18 2009 -0800
     1.3 @@ -46,24 +46,27 @@
     1.4  			GrowlApplicationTicket *newTicket = [[GrowlApplicationTicket alloc] initTicketFromPath:filename];
     1.5  			if (newTicket) {
     1.6  				NSString *applicationName = [newTicket applicationName];
     1.7 -				
     1.8 -				/* Growl used to generate a ticket for itself to display notifcations, but 
     1.9 -				 * but this has been removed for 1.1, referencing ticket #547. Thus we have
    1.10 -				 * the ticket loader remove the file if found */
    1.11 -				if([applicationName isEqual:@"Growl"])
    1.12 -				{
    1.13 -					[self removeTicketForApplicationName:@"Growl"];
    1.14 -					[mgr removeFileAtPath:filename handler:nil];
    1.15 +				if (!applicationName) {
    1.16 +					NSLog(@"Invalid ticket (no application name inside): %@", [filename lastPathComponent]);
    1.17 +				} else {
    1.18 +					/* Growl used to generate a ticket for itself to display notifcations, but 
    1.19 +				 	 * but this has been removed for 1.1, referencing ticket #547. Thus we have
    1.20 +				 	 * the ticket loader remove the file if found */
    1.21 +					if([applicationName isEqual:@"Growl"])
    1.22 +					{
    1.23 +						[self removeTicketForApplicationName:@"Growl"];
    1.24 +						[mgr removeFileAtPath:filename handler:nil];
    1.25 +					}
    1.26 +
    1.27 +					/*if we haven't already loaded a ticket for this application,
    1.28 +				 	 *	or if we're clobbering already-loaded tickets,
    1.29 +				 	 *	set this ticket in the dictionary.
    1.30 +				 	 */
    1.31 +					if (clobber || ![ticketsByApplicationName objectForKey:applicationName])
    1.32 +						[ticketsByApplicationName setObject:newTicket forKey:applicationName];
    1.33 +
    1.34 +					[newTicket release];
    1.35  				}
    1.36 -
    1.37 -				/*if we haven't already loaded a ticket for this application,
    1.38 -				 *	or if we're clobbering already-loaded tickets,
    1.39 -				 *	set this ticket in the dictionary.
    1.40 -				 */
    1.41 -				if (clobber || ![ticketsByApplicationName objectForKey:applicationName])
    1.42 -					[ticketsByApplicationName setObject:newTicket forKey:applicationName];
    1.43 -
    1.44 -				[newTicket release];
    1.45  			}
    1.46  		}
    1.47  	}