mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-27 06:08:21 +01:00
imageio/*dec,Read*: add input parameter checks
Change-Id: I5e069d6ea4da9d8c71be03ef99aad679dd1aad21
This commit is contained in:
parent
4eb5df28d1
commit
2a2773ea29
@ -266,6 +266,8 @@ int ReadJPEG(const uint8_t* const data, size_t data_size,
|
|||||||
JSAMPROW buffer[1];
|
JSAMPROW buffer[1];
|
||||||
JPEGReadContext ctx;
|
JPEGReadContext ctx;
|
||||||
|
|
||||||
|
if (data == NULL || data_size == 0 || pic == NULL) return 0;
|
||||||
|
|
||||||
(void)keep_alpha;
|
(void)keep_alpha;
|
||||||
memset(&ctx, 0, sizeof(ctx));
|
memset(&ctx, 0, sizeof(ctx));
|
||||||
ctx.data = data;
|
ctx.data = data;
|
||||||
|
@ -220,6 +220,8 @@ int ReadPNG(const uint8_t* const data, size_t data_size,
|
|||||||
int64_t stride;
|
int64_t stride;
|
||||||
uint8_t* volatile rgb = NULL;
|
uint8_t* volatile rgb = NULL;
|
||||||
|
|
||||||
|
if (data == NULL || data_size == 0 || pic == NULL) return 0;
|
||||||
|
|
||||||
context.data = data;
|
context.data = data;
|
||||||
context.data_size = data_size;
|
context.data_size = data_size;
|
||||||
|
|
||||||
|
@ -120,15 +120,18 @@ int ReadTIFF(const uint8_t* const data, size_t data_size,
|
|||||||
WebPPicture* const pic, int keep_alpha,
|
WebPPicture* const pic, int keep_alpha,
|
||||||
Metadata* const metadata) {
|
Metadata* const metadata) {
|
||||||
MyData my_data = { data, (toff_t)data_size, 0 };
|
MyData my_data = { data, (toff_t)data_size, 0 };
|
||||||
TIFF* const tif = TIFFClientOpen("Memory", "r", &my_data,
|
TIFF* tif;
|
||||||
MyRead, MyRead, MySeek, MyClose,
|
|
||||||
MySize, MyMapFile, MyUnmapFile);
|
|
||||||
uint32 width, height;
|
uint32 width, height;
|
||||||
uint32* raster;
|
uint32* raster;
|
||||||
int64_t alloc_size;
|
int64_t alloc_size;
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
tdir_t dircount;
|
tdir_t dircount;
|
||||||
|
|
||||||
|
if (data == NULL || data_size == 0 || pic == NULL) return 0;
|
||||||
|
|
||||||
|
tif = TIFFClientOpen("Memory", "r", &my_data,
|
||||||
|
MyRead, MyRead, MySeek, MyClose,
|
||||||
|
MySize, MyMapFile, MyUnmapFile);
|
||||||
if (tif == NULL) {
|
if (tif == NULL) {
|
||||||
fprintf(stderr, "Error! Cannot parse TIFF file\n");
|
fprintf(stderr, "Error! Cannot parse TIFF file\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -143,6 +143,8 @@ int ReadWebP(const uint8_t* const data, size_t data_size,
|
|||||||
WebPDecBuffer* const output_buffer = &config.output;
|
WebPDecBuffer* const output_buffer = &config.output;
|
||||||
WebPBitstreamFeatures* const bitstream = &config.input;
|
WebPBitstreamFeatures* const bitstream = &config.input;
|
||||||
|
|
||||||
|
if (data == NULL || data_size == 0 || pic == NULL) return 0;
|
||||||
|
|
||||||
// TODO(jzern): add Exif/XMP/ICC extraction.
|
// TODO(jzern): add Exif/XMP/ICC extraction.
|
||||||
if (metadata != NULL) {
|
if (metadata != NULL) {
|
||||||
fprintf(stderr, "Warning: metadata extraction from WebP is unsupported.\n");
|
fprintf(stderr, "Warning: metadata extraction from WebP is unsupported.\n");
|
||||||
|
@ -276,6 +276,8 @@ int ReadPictureWithWIC(const char* const filename,
|
|||||||
int has_alpha = 0;
|
int has_alpha = 0;
|
||||||
int64_t stride;
|
int64_t stride;
|
||||||
|
|
||||||
|
if (filename == NULL || pic == NULL) return 0;
|
||||||
|
|
||||||
IFS(CoInitialize(NULL));
|
IFS(CoInitialize(NULL));
|
||||||
IFS(CoCreateInstance(MAKE_REFGUID(CLSID_WICImagingFactory), NULL,
|
IFS(CoCreateInstance(MAKE_REFGUID(CLSID_WICImagingFactory), NULL,
|
||||||
CLSCTX_INPROC_SERVER,
|
CLSCTX_INPROC_SERVER,
|
||||||
|
Loading…
Reference in New Issue
Block a user