aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/SPPreferenceController.m3
1 files changed, 2 insertions, 1 deletions
diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m
index d27234d7..938accdc 100644
--- a/Source/SPPreferenceController.m
+++ b/Source/SPPreferenceController.m
@@ -280,7 +280,8 @@
if (([favorite isKindOfClass:[NSDictionary class]]) && ([favorite objectForKey:@"name"]) && ([favorite objectForKey:@"query"])) continue;
// By default make the query's name the first 32 characters of the query with '...' appended
- NSString *favoriteName = [[[favorite stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]] substringToIndex:32] stringByAppendingString:@"..."];
+ int idx = ( [favorite length] > 32 ) ? 32 : [favorite length];
+ NSString *favoriteName = [[[favorite stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]] substringToIndex:idx] stringByAppendingString:@"..."];
[queryFavoritesArray replaceObjectAtIndex:i withObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:favoriteName, favorite, nil] forKeys:[NSArray arrayWithObjects:@"name", @"query", nil]]];
}