]> granicus.if.org Git - imagemagick/commitdiff
handle short months in PNG tIME chunk generation
authorGlenn Randers-Pehrson <glennrp@gmail.com>
Fri, 4 Aug 2017 02:32:19 +0000 (22:32 -0400)
committerGlenn Randers-Pehrson <glennrp@gmail.com>
Fri, 4 Aug 2017 02:32:19 +0000 (22:32 -0400)
coders/png.c

index 0a5a6045596f94466fee47c33fdbd1e36a36a58a..150e0f0aaf0c2900aaa25d53ed5d98ffc41b6275 100644 (file)
@@ -8193,8 +8193,10 @@ static void write_tIME_chunk(Image *image,png_struct *ping,png_info *info,
       {
          ptime.hour = 0;
          ptime.day ++;
-         /* To do: fix this for short months */
-         if (ptime.day > 31)
+         /* To do: fix this for leap years */
+         if (ptime.day > 31 || (ptime.month == 2 && ptime.day > 28) ||
+             ((ptime.month == 4 || ptime.month == 6 || ptime.month == 9 ||
+             ptime.month == 11) && ptime.day > 30))
          {
             ptime.day = 1;
             ptime.month++;