diff mbox

[FFmpeg-devel,4/5] examples/filtering_video: fix memory leak

Message ID 20180514121802.14519-4-quinkblack@foxmail.com
State Accepted
Commit f24b2e64b0f328d321b56ab6119d8398380f0557
Headers show

Commit Message

Zhao Zhili May 14, 2018, 12:18 p.m. UTC
From: Zhao Zhili <wantlamy@gmail.com>

---
 doc/examples/filtering_video.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

Comments

Michael Niedermayer May 15, 2018, 7:09 p.m. UTC | #1
On Mon, May 14, 2018 at 08:18:01PM +0800, Zhao Zhili wrote:
> From: Zhao Zhili <wantlamy@gmail.com>
> 
> ---
>  doc/examples/filtering_video.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)

will apply


[...]
diff mbox

Patch

diff --git a/doc/examples/filtering_video.c b/doc/examples/filtering_video.c
index 2cc55e8..324d566 100644
--- a/doc/examples/filtering_video.c
+++ b/doc/examples/filtering_video.c
@@ -211,18 +211,21 @@  int main(int argc, char **argv)
 {
     int ret;
     AVPacket packet;
-    AVFrame *frame = av_frame_alloc();
-    AVFrame *filt_frame = av_frame_alloc();
+    AVFrame *frame;
+    AVFrame *filt_frame;
 
-    if (!frame || !filt_frame) {
-        perror("Could not allocate frame");
-        exit(1);
-    }
     if (argc != 2) {
         fprintf(stderr, "Usage: %s file\n", argv[0]);
         exit(1);
     }
 
+    frame = av_frame_alloc();
+    filt_frame = av_frame_alloc();
+    if (!frame || !filt_frame) {
+        perror("Could not allocate frame");
+        exit(1);
+    }
+
     if ((ret = open_input_file(argv[1])) < 0)
         goto end;
     if ((ret = init_filters(filter_descr)) < 0)