When the trailer is never written (or when a stream switches from non-animation mode to animation mode mid-stream), a cached packet (if existing) would leak. Fix this by adding a deinit function.
Unified · Split
| @@ -191,6 +191,13 @@ static int webp_write_trailer(AVFormatContext *s) · 190 unmodified lines | ||
| 191 | 191 | return 0; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | +static void webp_deinit(AVFormatContext *s) | |
| 195 | +{ | |
| 196 | + WebpContext *w = s->priv_data; | |
| 197 | + | |
| 198 | + av_packet_unref(&w->last_pkt); | |
| 199 | +} | |
| 200 | + | |
| 194 | 201 | #define OFFSET(x) offsetof(WebpContext, x) |
| 195 | 202 | #define ENC AV_OPT_FLAG_ENCODING_PARAM |
| 196 | 203 | static const AVOption options[] = { |
| @@ -214,6 +221,7 @@ AVOutputFormat ff_webp_muxer = { · 17 unmodified lines | ||
| 214 | 221 | .init = webp_init, |
| 215 | 222 | .write_packet = webp_write_packet, |
| 216 | 223 | .write_trailer = webp_write_trailer, |
| 224 | + .deinit = webp_deinit, | |
| 217 | 225 | .priv_class = &webp_muxer_class, |
| 218 | 226 | .flags = AVFMT_VARIABLE_FPS, |
| 219 | 227 | }; |