mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-25 13:18:22 +01:00
pngdec: fix build w/libpng < 1.4.x
after:
bc5092b1
pngdec: set memory functions
png_alloc_size_t was added in 1.4 use png_size_t in earlier versions
Change-Id: If65ac1c501e2d497b1be480095bf21f06ea7026a
This commit is contained in:
parent
bc5092b162
commit
637141bc7c
@ -30,12 +30,22 @@
|
||||
#include "./imageio_util.h"
|
||||
#include "./metadata.h"
|
||||
|
||||
#define LOCAL_PNG_VERSION ((PNG_LIBPNG_VER_MAJOR << 8) | PNG_LIBPNG_VER_MINOR)
|
||||
#define LOCAL_PNG_PREREQ(maj, min) \
|
||||
(LOCAL_PNG_VERSION >= (((maj) << 8) | (min)))
|
||||
|
||||
static void PNGAPI error_function(png_structp png, png_const_charp error) {
|
||||
if (error != NULL) fprintf(stderr, "libpng error: %s\n", error);
|
||||
longjmp(png_jmpbuf(png), 1);
|
||||
}
|
||||
|
||||
static png_voidp MallocFunc(png_structp png_ptr, png_alloc_size_t size) {
|
||||
#if LOCAL_PNG_PREREQ(1,4)
|
||||
typedef png_alloc_size_t LocalPngAllocSize;
|
||||
#else
|
||||
typedef png_size_t LocalPngAllocSize;
|
||||
#endif
|
||||
|
||||
static png_voidp MallocFunc(png_structp png_ptr, LocalPngAllocSize size) {
|
||||
(void)png_ptr;
|
||||
if (size != (size_t)size) return NULL;
|
||||
if (!ImgIoUtilCheckSizeArgumentsOverflow(size, 1)) return NULL;
|
||||
@ -186,11 +196,10 @@ static int ExtractMetadataFromPNG(png_structp png,
|
||||
{
|
||||
png_charp name;
|
||||
int comp_type;
|
||||
#if ((PNG_LIBPNG_VER_MAJOR << 8) | PNG_LIBPNG_VER_MINOR << 0) < \
|
||||
((1 << 8) | (5 << 0))
|
||||
png_charp profile;
|
||||
#else // >= libpng 1.5.0
|
||||
#if LOCAL_PNG_PREREQ(1,5)
|
||||
png_bytep profile;
|
||||
#else
|
||||
png_charp profile;
|
||||
#endif
|
||||
png_uint_32 len;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user