1 Star 0 Fork 98

lixinpeng/third_party_libpng

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
backport-libpng-1.6.37-enable-valid.patch 6.39 KB
一键复制 编辑 原始数据 按行查看 历史
achao 提交于 2023-12-20 09:27 . Description:libpng update version patch
diff --git a/arm/arm_init.c b/arm/arm_init.c
index ab22525b3..3a89998ab 100644
--- a/arm/arm_init.c
+++ b/arm/arm_init.c
@@ -31,23 +31,21 @@
* has partial support is contrib/arm-neon/linux.c - a generic Linux
* implementation which reads /proc/cpufino.
*/
-#include <signal.h> /* for sig_atomic_t */
-
#ifndef PNG_ARM_NEON_FILE
-# if defined(__aarch64__) || defined(_M_ARM64)
- /* ARM Neon is expected to be unconditionally available on ARM64. */
-# error "PNG_ARM_NEON_CHECK_SUPPORTED must not be defined on this platform"
-# elif defined(__linux__)
-# define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c"
-# else
-# error "No support for run-time ARM Neon checking; use compile-time options"
+# ifdef __linux__
+# define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c"
# endif
#endif
-static int png_have_neon(png_structp png_ptr);
#ifdef PNG_ARM_NEON_FILE
-# include PNG_ARM_NEON_FILE
-#endif
+
+#include <signal.h> /* for sig_atomic_t */
+static int png_have_neon(png_structp png_ptr);
+#include PNG_ARM_NEON_FILE
+
+#else /* PNG_ARM_NEON_FILE */
+# error "PNG_ARM_NEON_FILE undefined: no support for run-time ARM NEON checks"
+#endif /* PNG_ARM_NEON_FILE */
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
#ifndef PNG_ALIGNED_MEMORY_SUPPORTED
diff --git a/arm/palette_neon_intrinsics.c b/arm/palette_neon_intrinsics.c
index 92c7d6f9f..49909d475 100644
--- a/arm/palette_neon_intrinsics.c
+++ b/arm/palette_neon_intrinsics.c
@@ -65,12 +65,11 @@ png_do_expand_palette_rgba8_neon(png_structrp png_ptr, png_row_infop row_info,
png_uint_32 row_width = row_info->width;
const png_uint_32 *riffled_palette =
(const png_uint_32 *)png_ptr->riffled_palette;
- const png_uint_32 pixels_per_chunk = 4;
- png_uint_32 i;
+ const png_int_32 pixels_per_chunk = 4;
+ int i;
png_debug(1, "in png_do_expand_palette_rgba8_neon");
- PNG_UNUSED(row)
if (row_width < pixels_per_chunk)
return 0;
@@ -110,11 +109,10 @@ png_do_expand_palette_rgb8_neon(png_structrp png_ptr, png_row_infop row_info,
png_uint_32 row_width = row_info->width;
png_const_bytep palette = (png_const_bytep)png_ptr->palette;
const png_uint_32 pixels_per_chunk = 8;
- png_uint_32 i;
+ int i;
png_debug(1, "in png_do_expand_palette_rgb8_neon");
- PNG_UNUSED(row)
if (row_width <= pixels_per_chunk)
return 0;
diff --git a/pngread.c b/pngread.c
index 5ab922403..8fa7d9f16 100644
--- a/pngread.c
+++ b/pngread.c
@@ -3452,6 +3452,7 @@ png_image_read_background(png_voidp argument)
for (pass = 0; pass < passes; ++pass)
{
+ png_bytep row = png_voidcast(png_bytep, display->first_row);
unsigned int startx, stepx, stepy;
png_uint_32 y;
@@ -3556,6 +3557,8 @@ png_image_read_background(png_voidp argument)
inrow += 2; /* gray and alpha channel */
}
+
+ row += display->row_bytes;
}
}
}
diff --git a/pngrutil.c b/pngrutil.c
index ca060dd15..9ac8ec11f 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -2075,22 +2075,21 @@ png_handle_eXIf(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
png_byte buf[1];
png_crc_read(png_ptr, buf, 1);
info_ptr->eXIf_buf[i] = buf[0];
- if (i == 1)
+ if (i == 1 && buf[0] != 'M' && buf[0] != 'I'
+ && info_ptr->eXIf_buf[0] != buf[0])
{
- if ((buf[0] != 'M' && buf[0] != 'I') ||
- (info_ptr->eXIf_buf[0] != buf[0]))
- {
- png_crc_finish(png_ptr, length - 2);
- png_chunk_benign_error(png_ptr, "incorrect byte-order specifier");
- png_free(png_ptr, info_ptr->eXIf_buf);
- info_ptr->eXIf_buf = NULL;
- return;
- }
+ png_crc_finish(png_ptr, length);
+ png_chunk_benign_error(png_ptr, "incorrect byte-order specifier");
+ png_free(png_ptr, info_ptr->eXIf_buf);
+ info_ptr->eXIf_buf = NULL;
+ return;
}
}
- if (png_crc_finish(png_ptr, 0) == 0)
- png_set_eXIf_1(png_ptr, info_ptr, length, info_ptr->eXIf_buf);
+ if (png_crc_finish(png_ptr, 0) != 0)
+ return;
+
+ png_set_eXIf_1(png_ptr, info_ptr, length, info_ptr->eXIf_buf);
png_free(png_ptr, info_ptr->eXIf_buf);
info_ptr->eXIf_buf = NULL;
@@ -2126,9 +2125,8 @@ png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
num = length / 2 ;
- if (length != num * 2 ||
- num != (unsigned int)png_ptr->num_palette ||
- num > (unsigned int)PNG_MAX_PALETTE_LENGTH)
+ if (num != (unsigned int) png_ptr->num_palette ||
+ num > (unsigned int) PNG_MAX_PALETTE_LENGTH)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "invalid");
@@ -4622,11 +4620,11 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
*/
{
png_bytep temp = png_ptr->big_row_buf + 32;
- size_t extra = (size_t)temp & 0x0f;
+ int extra = (int)((temp - (png_bytep)0) & 0x0f);
png_ptr->row_buf = temp - extra - 1/*filter byte*/;
temp = png_ptr->big_prev_row + 32;
- extra = (size_t)temp & 0x0f;
+ extra = (int)((temp - (png_bytep)0) & 0x0f);
png_ptr->prev_row = temp - extra - 1/*filter byte*/;
}
#else
diff --git a/pngset.c b/pngset.c
index 8c372cf41..6444c0615 100644
--- a/pngset.c
+++ b/pngset.c
@@ -1019,9 +1019,6 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
info_ptr->trans_alpha = png_voidcast(png_bytep,
png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH));
memcpy(info_ptr->trans_alpha, trans_alpha, (size_t)num_trans);
-
- info_ptr->valid |= PNG_INFO_tRNS;
- info_ptr->free_me |= PNG_FREE_TRNS;
}
png_ptr->trans_alpha = info_ptr->trans_alpha;
}
diff --git a/pngwrite.c b/pngwrite.c
index 06c45d16a..b9a0ca188 100644
--- a/pngwrite.c
+++ b/pngwrite.c
@@ -489,16 +489,6 @@ png_convert_from_time_t(png_timep ptime, time_t ttime)
png_debug(1, "in png_convert_from_time_t");
tbuf = gmtime(&ttime);
- if (tbuf == NULL)
- {
- /* TODO: add a safe function which takes a png_ptr argument and raises
- * a png_error if the ttime argument is invalid and the call to gmtime
- * fails as a consequence.
- */
- memset(ptime, 0, sizeof(*ptime));
- return;
- }
-
png_convert_from_struct_tm(ptime, tbuf);
}
#endif
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lixinpeng1114/third_party_libpng.git
git@gitee.com:lixinpeng1114/third_party_libpng.git
lixinpeng1114
third_party_libpng
third_party_libpng
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385