• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1diff --git a/arm/arm_init.c b/arm/arm_init.c
2index ab22525b3..3a89998ab 100644
3--- a/arm/arm_init.c
4+++ b/arm/arm_init.c
5@@ -31,23 +31,21 @@
6  * has partial support is contrib/arm-neon/linux.c - a generic Linux
7  * implementation which reads /proc/cpufino.
8  */
9-#include <signal.h> /* for sig_atomic_t */
10-
11 #ifndef PNG_ARM_NEON_FILE
12-#  if defined(__aarch64__) || defined(_M_ARM64)
13-     /* ARM Neon is expected to be unconditionally available on ARM64. */
14-#    error "PNG_ARM_NEON_CHECK_SUPPORTED must not be defined on this platform"
15-#  elif defined(__linux__)
16-#    define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c"
17-#  else
18-#    error "No support for run-time ARM Neon checking; use compile-time options"
19+#  ifdef __linux__
20+#     define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c"
21 #  endif
22 #endif
23
24-static int png_have_neon(png_structp png_ptr);
25 #ifdef PNG_ARM_NEON_FILE
26-#  include PNG_ARM_NEON_FILE
27-#endif
28+
29+#include <signal.h> /* for sig_atomic_t */
30+static int png_have_neon(png_structp png_ptr);
31+#include PNG_ARM_NEON_FILE
32+
33+#else  /* PNG_ARM_NEON_FILE */
34+#  error "PNG_ARM_NEON_FILE undefined: no support for run-time ARM NEON checks"
35+#endif /* PNG_ARM_NEON_FILE */
36 #endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
37
38 #ifndef PNG_ALIGNED_MEMORY_SUPPORTED
39diff --git a/arm/palette_neon_intrinsics.c b/arm/palette_neon_intrinsics.c
40index 92c7d6f9f..49909d475 100644
41--- a/arm/palette_neon_intrinsics.c
42+++ b/arm/palette_neon_intrinsics.c
43@@ -65,12 +65,11 @@ png_do_expand_palette_rgba8_neon(png_structrp png_ptr, png_row_infop row_info,
44    png_uint_32 row_width = row_info->width;
45    const png_uint_32 *riffled_palette =
46       (const png_uint_32 *)png_ptr->riffled_palette;
47-   const png_uint_32 pixels_per_chunk = 4;
48-   png_uint_32 i;
49+   const png_int_32 pixels_per_chunk = 4;
50+   int i;
51
52    png_debug(1, "in png_do_expand_palette_rgba8_neon");
53
54-   PNG_UNUSED(row)
55    if (row_width < pixels_per_chunk)
56       return 0;
57
58@@ -110,11 +109,10 @@ png_do_expand_palette_rgb8_neon(png_structrp png_ptr, png_row_infop row_info,
59    png_uint_32 row_width = row_info->width;
60    png_const_bytep palette = (png_const_bytep)png_ptr->palette;
61    const png_uint_32 pixels_per_chunk = 8;
62-   png_uint_32 i;
63+   int i;
64
65    png_debug(1, "in png_do_expand_palette_rgb8_neon");
66
67-   PNG_UNUSED(row)
68    if (row_width <= pixels_per_chunk)
69       return 0;
70
71diff --git a/pngread.c b/pngread.c
72index 5ab922403..8fa7d9f16 100644
73--- a/pngread.c
74+++ b/pngread.c
75@@ -3452,6 +3452,7 @@ png_image_read_background(png_voidp argument)
76
77             for (pass = 0; pass < passes; ++pass)
78             {
79+               png_bytep row = png_voidcast(png_bytep, display->first_row);
80                unsigned int     startx, stepx, stepy;
81                png_uint_32      y;
82
83@@ -3556,6 +3557,8 @@ png_image_read_background(png_voidp argument)
84
85                         inrow += 2; /* gray and alpha channel */
86                      }
87+
88+                     row += display->row_bytes;
89                   }
90                }
91             }
92diff --git a/pngrutil.c b/pngrutil.c
93index ca060dd15..9ac8ec11f 100644
94--- a/pngrutil.c
95+++ b/pngrutil.c
96@@ -2075,22 +2075,21 @@ png_handle_eXIf(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
97       png_byte buf[1];
98       png_crc_read(png_ptr, buf, 1);
99       info_ptr->eXIf_buf[i] = buf[0];
100-      if (i == 1)
101+      if (i == 1 && buf[0] != 'M' && buf[0] != 'I'
102+                 && info_ptr->eXIf_buf[0] != buf[0])
103       {
104-         if ((buf[0] != 'M' && buf[0] != 'I') ||
105-             (info_ptr->eXIf_buf[0] != buf[0]))
106-         {
107-            png_crc_finish(png_ptr, length - 2);
108-            png_chunk_benign_error(png_ptr, "incorrect byte-order specifier");
109-            png_free(png_ptr, info_ptr->eXIf_buf);
110-            info_ptr->eXIf_buf = NULL;
111-            return;
112-         }
113+         png_crc_finish(png_ptr, length);
114+         png_chunk_benign_error(png_ptr, "incorrect byte-order specifier");
115+         png_free(png_ptr, info_ptr->eXIf_buf);
116+         info_ptr->eXIf_buf = NULL;
117+         return;
118       }
119    }
120
121-   if (png_crc_finish(png_ptr, 0) == 0)
122-      png_set_eXIf_1(png_ptr, info_ptr, length, info_ptr->eXIf_buf);
123+   if (png_crc_finish(png_ptr, 0) != 0)
124+      return;
125+
126+   png_set_eXIf_1(png_ptr, info_ptr, length, info_ptr->eXIf_buf);
127
128    png_free(png_ptr, info_ptr->eXIf_buf);
129    info_ptr->eXIf_buf = NULL;
130@@ -2126,9 +2125,8 @@ png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
131
132    num = length / 2 ;
133
134-   if (length != num * 2 ||
135-       num != (unsigned int)png_ptr->num_palette ||
136-       num > (unsigned int)PNG_MAX_PALETTE_LENGTH)
137+   if (num != (unsigned int) png_ptr->num_palette ||
138+       num > (unsigned int) PNG_MAX_PALETTE_LENGTH)
139    {
140       png_crc_finish(png_ptr, length);
141       png_chunk_benign_error(png_ptr, "invalid");
142@@ -4622,11 +4620,11 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
143        */
144       {
145          png_bytep temp = png_ptr->big_row_buf + 32;
146-         size_t extra = (size_t)temp & 0x0f;
147+         int extra = (int)((temp - (png_bytep)0) & 0x0f);
148          png_ptr->row_buf = temp - extra - 1/*filter byte*/;
149
150          temp = png_ptr->big_prev_row + 32;
151-         extra = (size_t)temp & 0x0f;
152+         extra = (int)((temp - (png_bytep)0) & 0x0f);
153          png_ptr->prev_row = temp - extra - 1/*filter byte*/;
154       }
155 #else
156diff --git a/pngset.c b/pngset.c
157index 8c372cf41..6444c0615 100644
158--- a/pngset.c
159+++ b/pngset.c
160@@ -1019,9 +1019,6 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
161           info_ptr->trans_alpha = png_voidcast(png_bytep,
162               png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH));
163           memcpy(info_ptr->trans_alpha, trans_alpha, (size_t)num_trans);
164-
165-          info_ptr->valid |= PNG_INFO_tRNS;
166-          info_ptr->free_me |= PNG_FREE_TRNS;
167        }
168        png_ptr->trans_alpha = info_ptr->trans_alpha;
169    }
170diff --git a/pngwrite.c b/pngwrite.c
171index 06c45d16a..b9a0ca188 100644
172--- a/pngwrite.c
173+++ b/pngwrite.c
174@@ -489,16 +489,6 @@ png_convert_from_time_t(png_timep ptime, time_t ttime)
175    png_debug(1, "in png_convert_from_time_t");
176
177    tbuf = gmtime(&ttime);
178-   if (tbuf == NULL)
179-   {
180-      /* TODO: add a safe function which takes a png_ptr argument and raises
181-       * a png_error if the ttime argument is invalid and the call to gmtime
182-       * fails as a consequence.
183-       */
184-      memset(ptime, 0, sizeof(*ptime));
185-      return;
186-   }
187-
188    png_convert_from_struct_tm(ptime, tbuf);
189 }
190 #endif
191