]> err.no Git - scalable-opengroupware.org/commitdiff
hardened against nil arguments
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Sat, 30 Jul 2005 16:41:41 +0000 (16:41 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Sat, 30 Jul 2005 16:41:41 +0000 (16:41 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@922 d1b88da0-ebda-0310-925b-ed51d893ca5b

UI/SOGoUI/ChangeLog
UI/SOGoUI/SOGoDateFormatter.m
UI/SOGoUI/Version

index 7c10b6e8cabf93f019b897852ae4aaff0a5199ee..b7b1ba988678f54ef350d48b92349a76196734bf 100644 (file)
@@ -1,3 +1,7 @@
+2005-07-30  Helge Hess  <helge.hess@opengroupware.org>
+
+       * SOGoDateFormatter.m: hardened against nil arguments (v0.9.35)
+
 2005-07-21  Marcus Mueller  <znek@mulle-kybernetik.com>
 
        * UIxComponent.m: changed -userFolderPath to generate the path to the
index e5cf1957bb8b3ff368e577a41d0838772ca25a64..331243426956350cd3ed5de4155cf24e2df02abb 100644 (file)
 - (id)initWithLocale:(NSDictionary *)_locale {
   if ((self = [super init])) {
     self->locale = [_locale retain];
-    if ([[self->locale objectForKey:@"NSLocaleCode"] isEqualToString:@"fr"]) {
+    
+    if ([[self->locale objectForKey:@"NSLocaleCode"] isEqualToString:@"fr"])
       [self setFrenchDateFormat];
-    }
-    else {
+    else
       [self setISODateFormat];
-    }
   }
   return self;
 }
 /* Private API */
 
 - (NSString *)isoDateFormatForDate:(NSCalendarDate *)_date {
-  return [NSString stringWithFormat:@"%04d-%02d-%02d",
-                  [_date yearOfCommonEra],
-                  [_date monthOfYear],
-                  [_date dayOfMonth]];
+  char buf[16];
+  
+  if (_date == nil) return nil;
+  snprintf(buf, sizeof(buf), 
+          "%04d-%02d-%02d",
+          [_date yearOfCommonEra], [_date monthOfYear], [_date dayOfMonth]);
+  return [NSString stringWithCString:buf];
 }
 
 - (NSString *)frenchDateFormatForDate:(NSCalendarDate *)_date {
-  return [NSString stringWithFormat:@"%02d/%02d/%04d",
-                                      [_date dayOfMonth],
-                                      [_date monthOfYear],
-                                      [_date yearOfCommonEra]];
+  char buf[16];
+  
+  if (_date == nil) return nil;
+  snprintf(buf, sizeof(buf), 
+          "%02d/%02d/%04d",
+          [_date dayOfMonth], [_date monthOfYear], [_date yearOfCommonEra]);
+  return [NSString stringWithCString:buf];
 }
 
 - (NSString *)fullWeekdayNameAndDetailsForDate:(NSCalendarDate *)_date {
   NSMutableString *desc;
   
+  if (_date == nil) return nil;
+  
   desc = [NSMutableString stringWithCapacity:24];
   [desc appendString:[self fullDayOfWeek:[_date dayOfWeek]]];
   [desc appendString:@", "];
index 3a66b827fa0b47b504385ce013b0c262d65bff5e..21352434eb4dbfa5f96b0648e03d1ce13eaa22f9 100644 (file)
@@ -1,5 +1,5 @@
 # version file
 
-SUBMINOR_VERSION:=34
+SUBMINOR_VERSION:=35
 
 # v0.9.18 requires NGExtensions v4.5.136