mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-27 06:08:21 +01:00
Merge changes I479bc487,I39864691,I5d486c2c,I186d13be into main
* changes: mux{edit,internal}: fix leaks on error ExUtilInitCommandLineArguments: fix leak on error anim_util: fix leaks on error gif2webp: fix segfault on OOM
This commit is contained in:
commit
e8e77b9c47
@ -241,7 +241,7 @@ static int ReadAnimatedWebP(const char filename[],
|
|||||||
image->bgcolor = anim_info.bgcolor;
|
image->bgcolor = anim_info.bgcolor;
|
||||||
|
|
||||||
// Allocate frames.
|
// Allocate frames.
|
||||||
if (!AllocateFrames(image, anim_info.frame_count)) return 0;
|
if (!AllocateFrames(image, anim_info.frame_count)) goto End;
|
||||||
|
|
||||||
// Decode frames.
|
// Decode frames.
|
||||||
while (WebPAnimDecoderHasMoreFrames(dec)) {
|
while (WebPAnimDecoderHasMoreFrames(dec)) {
|
||||||
@ -558,7 +558,10 @@ static int ReadAnimatedGIF(const char filename[], AnimatedImage* const image,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Allocate frames.
|
// Allocate frames.
|
||||||
AllocateFrames(image, frame_count);
|
if (!AllocateFrames(image, frame_count)) {
|
||||||
|
DGifCloseFile(gif, NULL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
canvas_width = image->canvas_width;
|
canvas_width = image->canvas_width;
|
||||||
canvas_height = image->canvas_height;
|
canvas_height = image->canvas_height;
|
||||||
|
@ -103,7 +103,10 @@ int ExUtilInitCommandLineArguments(int argc, const char* argv[],
|
|||||||
}
|
}
|
||||||
args->own_argv_ = 1;
|
args->own_argv_ = 1;
|
||||||
args->argv_ = (const char**)WebPMalloc(MAX_ARGC * sizeof(*args->argv_));
|
args->argv_ = (const char**)WebPMalloc(MAX_ARGC * sizeof(*args->argv_));
|
||||||
if (args->argv_ == NULL) return 0;
|
if (args->argv_ == NULL) {
|
||||||
|
ExUtilDeleteCommandLineArguments(args);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
argc = 0;
|
argc = 0;
|
||||||
for (cur = strtok((char*)args->argv_data_.bytes, sep);
|
for (cur = strtok((char*)args->argv_data_.bytes, sep);
|
||||||
@ -111,6 +114,7 @@ int ExUtilInitCommandLineArguments(int argc, const char* argv[],
|
|||||||
cur = strtok(NULL, sep)) {
|
cur = strtok(NULL, sep)) {
|
||||||
if (argc == MAX_ARGC) {
|
if (argc == MAX_ARGC) {
|
||||||
fprintf(stderr, "ERROR: Arguments limit %d reached\n", MAX_ARGC);
|
fprintf(stderr, "ERROR: Arguments limit %d reached\n", MAX_ARGC);
|
||||||
|
ExUtilDeleteCommandLineArguments(args);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
assert(strlen(cur) != 0);
|
assert(strlen(cur) != 0);
|
||||||
|
@ -314,8 +314,11 @@ int main(int argc, const char* argv[]) {
|
|||||||
frame.use_argb = 1;
|
frame.use_argb = 1;
|
||||||
if (!WebPPictureAlloc(&frame)) goto End;
|
if (!WebPPictureAlloc(&frame)) goto End;
|
||||||
GIFClearPic(&frame, NULL);
|
GIFClearPic(&frame, NULL);
|
||||||
WebPPictureCopy(&frame, &curr_canvas);
|
if (!(WebPPictureCopy(&frame, &curr_canvas) &&
|
||||||
WebPPictureCopy(&frame, &prev_canvas);
|
WebPPictureCopy(&frame, &prev_canvas))) {
|
||||||
|
fprintf(stderr, "Error allocating canvas.\n");
|
||||||
|
goto End;
|
||||||
|
}
|
||||||
|
|
||||||
// Background color.
|
// Background color.
|
||||||
GIFGetBackgroundColor(gif->SColorMap, gif->SBackGroundColor,
|
GIFGetBackgroundColor(gif->SColorMap, gif->SBackGroundColor,
|
||||||
|
@ -70,6 +70,7 @@ void WebPMuxDelete(WebPMux* mux) {
|
|||||||
err = ChunkAssignData(&chunk, data, copy_data, tag); \
|
err = ChunkAssignData(&chunk, data, copy_data, tag); \
|
||||||
if (err == WEBP_MUX_OK) { \
|
if (err == WEBP_MUX_OK) { \
|
||||||
err = ChunkSetHead(&chunk, (LIST)); \
|
err = ChunkSetHead(&chunk, (LIST)); \
|
||||||
|
if (err != WEBP_MUX_OK) ChunkRelease(&chunk); \
|
||||||
} \
|
} \
|
||||||
return err; \
|
return err; \
|
||||||
}
|
}
|
||||||
|
@ -155,17 +155,18 @@ WebPMuxError ChunkSetHead(WebPChunk* const chunk,
|
|||||||
|
|
||||||
WebPMuxError ChunkAppend(WebPChunk* const chunk,
|
WebPMuxError ChunkAppend(WebPChunk* const chunk,
|
||||||
WebPChunk*** const chunk_list) {
|
WebPChunk*** const chunk_list) {
|
||||||
|
WebPMuxError err;
|
||||||
assert(chunk_list != NULL && *chunk_list != NULL);
|
assert(chunk_list != NULL && *chunk_list != NULL);
|
||||||
|
|
||||||
if (**chunk_list == NULL) {
|
if (**chunk_list == NULL) {
|
||||||
ChunkSetHead(chunk, *chunk_list);
|
err = ChunkSetHead(chunk, *chunk_list);
|
||||||
} else {
|
} else {
|
||||||
WebPChunk* last_chunk = **chunk_list;
|
WebPChunk* last_chunk = **chunk_list;
|
||||||
while (last_chunk->next_ != NULL) last_chunk = last_chunk->next_;
|
while (last_chunk->next_ != NULL) last_chunk = last_chunk->next_;
|
||||||
ChunkSetHead(chunk, &last_chunk->next_);
|
err = ChunkSetHead(chunk, &last_chunk->next_);
|
||||||
*chunk_list = &last_chunk->next_;
|
if (err == WEBP_MUX_OK) *chunk_list = &last_chunk->next_;
|
||||||
}
|
}
|
||||||
return WEBP_MUX_OK;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user