]> git.sesse.net Git - vlc/commitdiff
mediacodec: add a NULL pointer check after getting the profileLevels field
authorFelix Abecassis <felix.abecassis@gmail.com>
Fri, 14 Feb 2014 18:06:13 +0000 (19:06 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Fri, 14 Feb 2014 18:10:38 +0000 (19:10 +0100)
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/codec/omxil/android_mediacodec.c

index 9150acc4cdf552187f2c2f8baf15a77469026d7e..06ece8f496cb4b319c7529d314980817d65addd1 100644 (file)
@@ -305,10 +305,11 @@ static int OpenDecoder(vlc_object_t *p_this)
             continue;
         }
 
-       jobject codec_capabilities = (*env)->CallObjectMethod(env, info, p_sys->get_capabilities_for_type,
-                                                             (*env)->NewStringUTF(env, mime));
-       jobject profile_levels = (*env)->GetObjectField(env, codec_capabilities, p_sys->profile_levels_field);
-       int profile_levels_len = (*env)->GetArrayLength(env, profile_levels);
+        jobject codec_capabilities = (*env)->CallObjectMethod(env, info, p_sys->get_capabilities_for_type,
+                                                              (*env)->NewStringUTF(env, mime));
+        jobject profile_levels = (*env)->GetObjectField(env, codec_capabilities, p_sys->profile_levels_field);
+        int profile_levels_len = profile_levels ? (*env)->GetArrayLength(env, profile_levels) : 0;
+        msg_Dbg(p_dec, "Number of profile levels: %d", profile_levels_len);
 
         jobject types = (*env)->CallObjectMethod(env, info, p_sys->get_supported_types);
         int num_types = (*env)->GetArrayLength(env, types);
@@ -319,7 +320,7 @@ static int OpenDecoder(vlc_object_t *p_this)
                 /* The mime type is matching for this component. We
                    now check if the capabilities of the codec is
                    matching the video format. */
-                if (p_dec->fmt_in.i_codec == VLC_CODEC_H264 && fmt_profile) {
+                if (p_dec->fmt_in.i_codec == VLC_CODEC_H264 && fmt_profile && profile_levels_len) {
                     for (int i = 0; i < profile_levels_len && !found; ++i) {
                         jobject profile_level = (*env)->GetObjectArrayElement(env, profile_levels, i);