adium 5114:e6735e611e0e: This should fix a crash when reading in...

commits at adium.im commits at adium.im
Fri Oct 12 13:43:38 UTC 2012


details:	http://hg.adium.im/adium/rev/e6735e611e0e
revision:	5114:e6735e611e0e
branch:		(none)
author:		Thijs Alkemade <thijsalkemade at gmail.com>
date:		Fri Oct 12 15:43:24 2012 +0200

This should fix a crash when reading in the random color names.

diffs (74 lines):

diff -r d576de4f3583 -r e6735e611e0e Frameworks/AIUtilities Framework/Source/AIColorAdditions.m
--- a/Frameworks/AIUtilities Framework/Source/AIColorAdditions.m	Wed Oct 10 23:23:42 2012 +0200
+++ b/Frameworks/AIUtilities Framework/Source/AIColorAdditions.m	Fri Oct 12 15:43:24 2012 +0200
@@ -68,31 +68,29 @@
 	};
 	
 	NSDictionary *result = nil;
+	NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
 	
 	//the rgb.txt file that comes with Mac OS X 10.3.8 contains 752 entries.
 	//we create 3 autoreleased objects for each one.
 	//best to not pollute our caller's autorelease pool.
 	@autoreleasepool {
-		
-		NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
-		
 		for (unsigned i = 0; i < length; ++i) {
 			if (state.inComment) {
 				if (ch[i] == '\n') state.inComment = NO;
 			} else if (ch[i] == '\n') {
 				if (state.prevChar != '\n') { //ignore blank lines
 					if (	! ((state.redStart   != NULL)
-						   && (state.greenStart != NULL)
-						   && (state.blueStart  != NULL)
-						   && (state.nameStart  != NULL)))
+							   && (state.greenStart != NULL)
+							   && (state.blueStart  != NULL)
+							   && (state.nameStart  != NULL)))
 					{
-	#if COLOR_DEBUG
+#if COLOR_DEBUG
 						NSLog(@"Parse error reading rgb.txt file: a non-comment line was encountered that did not have all four of red (%p), green (%p), blue (%p), and name (%p) - index is %u",
 							  state.redStart,
 							  state.greenStart,
 							  state.blueStart,
 							  state.nameStart, i);
-	#endif
+#endif
 						goto end;
 					}
 					
@@ -111,8 +109,8 @@
 						//only add the lowercase version if it isn't already defined
 						[mutableDict setObject:color forKey:lowercaseName];
 					}
-
-					state.redStart = state.greenStart = state.blueStart = state.nameStart = 
+					
+					state.redStart = state.greenStart = state.blueStart = state.nameStart =
 					state.redEnd   = state.greenEnd   = state.blueEnd   = NULL;
 				} //if (prevChar != '\n')
 			} else if ((ch[i] != ' ') && (ch[i] != '\t')) {
@@ -135,14 +133,14 @@
 			}
 			state.prevChar = ch[i];
 		} //for (unsigned i = 0; i < length; ++i)
-
-		//why not use -copy? because this is subclass-friendly.
-		//you can call this method on NSMutableDictionary and get a mutable dictionary back.
-		result = [[self alloc] initWithDictionary:mutableDict];
-	end:
-
-		return result;
 	}
+	
+	//why not use -copy? because this is subclass-friendly.
+	//you can call this method on NSMutableDictionary and get a mutable dictionary back.
+	result = [[self alloc] initWithDictionary:mutableDict];
+end:
+	
+	return result;
 }
 
 @end




More information about the commits mailing list