commit a677ba2b55d3d73f42a1d62b56a7c9d5a9cf5378
parent d6d66ace68800dfd7cc40a42b41c8e0642cfc178
Author: bsandro <email@bsandro.tech>
Date: Thu, 4 May 2023 00:18:26 +0300
alloc_image() fix
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/main.c b/src/main.c
@@ -33,6 +33,7 @@ typedef struct {
} AnimatedImage;
void alloc_image(AnimatedImage *img, uint32_t frame_count) {
+ assert(frame_count > 0);
uint8_t *mem = NULL;
DecodedFrame *frames = NULL;
const uint64_t rgba_size = img->width * img->height * NUM_CHANNELS;
@@ -115,11 +116,11 @@ int read_webp(const char *fname, AnimatedImage *anim) {
return -1;
}
- alloc_image(anim, anim_info.frame_count);
anim->width = anim_info.canvas_width;
anim->height = anim_info.canvas_height;
anim->loop_count = anim_info.loop_count;
anim->bgcolor = anim_info.bgcolor;
+ alloc_image(anim, anim_info.frame_count);
uint32_t frame_index = 0;
int prev_ts = 0;