examples/vaapi_encode: Fix leak on hwframe init failure
authorMark Thompson <sw@jkqxz.net>
Fri, 1 Dec 2017 21:06:42 +0000 (21:06 +0000)
committerMark Thompson <sw@jkqxz.net>
Fri, 1 Dec 2017 21:12:45 +0000 (21:12 +0000)
Fixes CID #1424882.

doc/examples/vaapi_encode.c

index 866b03d..f66a4a7 100644 (file)
@@ -58,6 +58,7 @@ static int set_hwframe_ctx(AVCodecContext *ctx, AVBufferRef *hw_device_ctx)
     if ((err = av_hwframe_ctx_init(hw_frames_ref)) < 0) {
         fprintf(stderr, "Failed to initialize VAAPI frame context."
                 "Error code: %s\n",av_err2str(err));
+        av_buffer_unref(&hw_frames_ref);
         return err;
     }
     ctx->hw_frames_ctx = av_buffer_ref(hw_frames_ref);