diff mbox series

[FFmpeg-devel,6/6] avutil/hwcontext_qsv: Remove redundant check

Message ID AM7PR03MB6660323763BCD58FE91900E28FA69@AM7PR03MB6660.eurprd03.prod.outlook.com
State New
Headers show
Series [FFmpeg-devel,1/6] avcodec/qsvenc: Fix leak and crash when encoding H.264 due to A53_CC
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 26, 2021, 6:40 a.m. UTC
It has already been checked immediately before that said
AVDictionaryEntry exists; checking again is redundant.
Furthermore, av_hwdevice_find_type_by_name() requires its argument
to be non-NULL, so adding a codepath that automatically calls it
with that parameter is nonsense. The same goes for the argument
corresponding to %s.

Fixes Coverity issue 1491394.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
If one wanted to sanitize something here, one should check for
"if (e && e->value)" instead. Or unconditionally error out if (e &&
!e->value).

 libavutil/hwcontext_qsv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 4ed50a31a0..268be9f8a1 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -1463,10 +1463,10 @@  static int qsv_device_create(AVHWDeviceContext *ctx, const char *device,
 
     e = av_dict_get(opts, "child_device_type", NULL, 0);
     if (e) {
-        child_device_type = av_hwdevice_find_type_by_name(e ? e->value : NULL);
+        child_device_type = av_hwdevice_find_type_by_name(e->value);
         if (child_device_type == AV_HWDEVICE_TYPE_NONE) {
             av_log(ctx, AV_LOG_ERROR, "Unknown child device type "
-                   "\"%s\".\n", e ? e->value : NULL);
+                   "\"%s\".\n", e->value);
             return AVERROR(EINVAL);
         }
     } else if (CONFIG_VAAPI) {