mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-26 05:38:22 +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;
|
||||
|
||||
// Allocate frames.
|
||||
if (!AllocateFrames(image, anim_info.frame_count)) return 0;
|
||||
if (!AllocateFrames(image, anim_info.frame_count)) goto End;
|
||||
|
||||
// Decode frames.
|
||||
while (WebPAnimDecoderHasMoreFrames(dec)) {
|
||||
@ -558,7 +558,10 @@ static int ReadAnimatedGIF(const char filename[], AnimatedImage* const image,
|
||||
}
|
||||
}
|
||||
// Allocate frames.
|
||||
AllocateFrames(image, frame_count);
|
||||
if (!AllocateFrames(image, frame_count)) {
|
||||
DGifCloseFile(gif, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
canvas_width = image->canvas_width;
|
||||
canvas_height = image->canvas_height;
|
||||
|
@ -103,7 +103,10 @@ int ExUtilInitCommandLineArguments(int argc, const char* argv[],
|
||||
}
|
||||
args->own_argv_ = 1;
|
||||
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;
|
||||
for (cur = strtok((char*)args->argv_data_.bytes, sep);
|
||||
@ -111,6 +114,7 @@ int ExUtilInitCommandLineArguments(int argc, const char* argv[],
|
||||
cur = strtok(NULL, sep)) {
|
||||
if (argc == MAX_ARGC) {
|
||||
fprintf(stderr, "ERROR: Arguments limit %d reached\n", MAX_ARGC);
|
||||
ExUtilDeleteCommandLineArguments(args);
|
||||
return 0;
|
||||
}
|
||||
assert(strlen(cur) != 0);
|
||||
|
@ -314,8 +314,11 @@ int main(int argc, const char* argv[]) {
|
||||
frame.use_argb = 1;
|
||||
if (!WebPPictureAlloc(&frame)) goto End;
|
||||
GIFClearPic(&frame, NULL);
|
||||
WebPPictureCopy(&frame, &curr_canvas);
|
||||
WebPPictureCopy(&frame, &prev_canvas);
|
||||
if (!(WebPPictureCopy(&frame, &curr_canvas) &&
|
||||
WebPPictureCopy(&frame, &prev_canvas))) {
|
||||
fprintf(stderr, "Error allocating canvas.\n");
|
||||
goto End;
|
||||
}
|
||||
|
||||
// Background color.
|
||||
GIFGetBackgroundColor(gif->SColorMap, gif->SBackGroundColor,
|
||||
|
@ -70,6 +70,7 @@ void WebPMuxDelete(WebPMux* mux) {
|
||||
err = ChunkAssignData(&chunk, data, copy_data, tag); \
|
||||
if (err == WEBP_MUX_OK) { \
|
||||
err = ChunkSetHead(&chunk, (LIST)); \
|
||||
if (err != WEBP_MUX_OK) ChunkRelease(&chunk); \
|
||||
} \
|
||||
return err; \
|
||||
}
|
||||
|
@ -155,17 +155,18 @@ WebPMuxError ChunkSetHead(WebPChunk* const chunk,
|
||||
|
||||
WebPMuxError ChunkAppend(WebPChunk* const chunk,
|
||||
WebPChunk*** const chunk_list) {
|
||||
WebPMuxError err;
|
||||
assert(chunk_list != NULL && *chunk_list != NULL);
|
||||
|
||||
if (**chunk_list == NULL) {
|
||||
ChunkSetHead(chunk, *chunk_list);
|
||||
err = ChunkSetHead(chunk, *chunk_list);
|
||||
} else {
|
||||
WebPChunk* last_chunk = **chunk_list;
|
||||
while (last_chunk->next_ != NULL) last_chunk = last_chunk->next_;
|
||||
ChunkSetHead(chunk, &last_chunk->next_);
|
||||
*chunk_list = &last_chunk->next_;
|
||||
err = ChunkSetHead(chunk, &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