diff mbox series

[FFmpeg-devel,2/3] avcodec/nvdec: Use av_buffer_replace() where appropriate

Message ID DB6PR0101MB22144871B90463FDA35FC68B8F619@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com
State Accepted
Commit 56973eb6874316b405e37097168b1f2dd89a1e7f
Headers show
Series [FFmpeg-devel,1/3] avcodec/nvdec: Check av_buffer_ref() | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Aug. 6, 2022, 5:39 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/nvdec.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Timo Rothenpieler Aug. 7, 2022, 8:48 a.m. UTC | #1
First two patches LGTM
diff mbox series

Patch

diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index 15665b83bb..fbaedf0b6b 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -524,12 +524,9 @@  static int nvdec_retrieve_data(void *logctx, AVFrame *frame)
         goto copy_fail;
     }
 
-    av_buffer_unref(&frame->hw_frames_ctx);
-    frame->hw_frames_ctx = av_buffer_ref(decoder->real_hw_frames_ref);
-    if (!frame->hw_frames_ctx) {
-        ret = AVERROR(ENOMEM);
+    ret = av_buffer_replace(&frame->hw_frames_ctx, decoder->real_hw_frames_ref);
+    if (ret < 0)
         goto copy_fail;
-    }
 
     unmap_data->idx = cf->idx;
     if (!(unmap_data->idx_ref     = av_buffer_ref(cf->idx_ref)) ||