extras/ShortDate: Fixed crash on invalid month
authorJerome St-Louis <jerome@ecere.com>
Tue, 21 Aug 2012 18:59:20 +0000 (14:59 -0400)
committerJerome St-Louis <jerome@ecere.com>
Tue, 21 Aug 2012 18:59:20 +0000 (14:59 -0400)
extras/types/ShortDate.ec

index 7b603df..eab983f 100644 (file)
@@ -13,7 +13,12 @@ public struct ShortDate : Date
          "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
       };
       if(day || month || year)
-         sprintf(stringOutput, "%s %d, %d", months[month], day, year);
+      {
+         if(month >= january && month <= december)
+            sprintf(stringOutput, "%s %d, %d", months[month], day, year);
+         else
+            strcpy(stringOutput, "Invalid date");
+      }
       else
          stringOutput[0] = 0;
       return stringOutput;