]> granicus.if.org Git - imagemagick/commitdiff
Handle short months in png_write_iTIME()
authorGlenn Randers-Pehrson <glennrp@gmail.com>
Sun, 20 Aug 2017 19:48:19 +0000 (15:48 -0400)
committerGlenn Randers-Pehrson <glennrp@gmail.com>
Sun, 20 Aug 2017 19:48:19 +0000 (15:48 -0400)
coders/png.c

index 8eedbeaa88d8a87e87e04dc91c0a6bad2c4c95f5..3604ed570369f7aeab5e7b1bbda09b3ce01e2e58 100644 (file)
@@ -8202,7 +8202,16 @@ static void write_tIME_chunk(Image *image,png_struct *ping,png_info *info,
     {
       /* wrong for short months */
       ptime.month--;
-      ptime.day=31;
+      if(ptime.month == 2)
+        ptime.day=28;
+      else
+      {
+        if(ptime.month == 4 || ptime.month == 6 || ptime.month == 9 ||
+           ptime.month == 11)
+          ptime.day=30;
+        else
+          ptime.day=31;
+      }
     }
     if (ptime.month == 0)
     {