]> git.sesse.net Git - ffmpeg/commitdiff
dnn/dnn_backend_native: Don't use asserts for checks
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Wed, 10 Mar 2021 13:00:26 +0000 (14:00 +0100)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Thu, 11 Mar 2021 11:39:01 +0000 (12:39 +0100)
asserts should not be used instead of ordinary input checks.
Yet the native DNN backend did it: get_input_native() asserted that
the first dimension was one, despite this value coming directly from
the input file without having been sanitized.

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavfilter/dnn/dnn_backend_native.c

index 828dcf8b37ab0a00e8a82f7cd0b6501e73b917c2..c7a2ad223aa5e7f0c91e5a85e50ad6d4e9daca2c 100644 (file)
@@ -232,6 +232,8 @@ DNNModel *ff_dnn_load_model_native(const char *model_filename, DNNFunctionType f
             oprd->dims[dim] = (int32_t)avio_rl32(model_file_context);
             dnn_size += 4;
         }
+        if (oprd->type == DOT_INPUT && oprd->dims[0] != 1)
+            goto fail;
 
         oprd->isNHWC = 1;
     }