diff --git a/libavutil/opt.c b/libavutil/opt.c
index f2b947337e9a3e4b33b4652d35415b6105e49cf0..cba5b29ac6f3a6f428ed27573a720cf0d14c625c 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -650,6 +650,9 @@ const AVOption *av_opt_find2(void *obj, const char *name, const char *unit,
     const AVClass  *c = *(AVClass**)obj;
     const AVOption *o = NULL;
 
+    if (!c)
+        return NULL;
+
     if (search_flags & AV_OPT_SEARCH_CHILDREN) {
         if (search_flags & AV_OPT_SEARCH_FAKE_OBJ) {
             const AVClass *child = NULL;