[FFmpeg-cvslog] avcodec/nvenc: check pop_context return value

Timo Rothenpieler git at videolan.org
Sat Nov 18 01:47:06 EET 2017


ffmpeg | branch: master | Timo Rothenpieler <timo at rothenpieler.org> | Wed Nov 15 18:33:31 2017 +0100| [4e93f00b06d9623ea9639ba7185cdacdf11c2672] | committer: Timo Rothenpieler

avcodec/nvenc: check pop_context return value

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4e93f00b06d9623ea9639ba7185cdacdf11c2672
---

 libavcodec/nvenc.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 0139e70c3b..e07280b568 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1293,7 +1293,7 @@ static av_cold int nvenc_alloc_surface(AVCodecContext *avctx, int idx)
 static av_cold int nvenc_setup_surfaces(AVCodecContext *avctx)
 {
     NvencContext *ctx = avctx->priv_data;
-    int i, res;
+    int i, res = 0, res2;
 
     ctx->surfaces = av_mallocz_array(ctx->nb_surfaces, sizeof(*ctx->surfaces));
     if (!ctx->surfaces)
@@ -1320,17 +1320,15 @@ static av_cold int nvenc_setup_surfaces(AVCodecContext *avctx)
 
     for (i = 0; i < ctx->nb_surfaces; i++) {
         if ((res = nvenc_alloc_surface(avctx, i)) < 0)
-        {
-            nvenc_pop_context(avctx);
-            return res;
-        }
+            goto fail;
     }
 
-    res = nvenc_pop_context(avctx);
-    if (res < 0)
-        return res;
+fail:
+    res2 = nvenc_pop_context(avctx);
+    if (res2 < 0)
+        return res2;
 
-    return 0;
+    return res;
 }
 
 static av_cold int nvenc_setup_extradata(AVCodecContext *avctx)



More information about the ffmpeg-cvslog mailing list