Commit 7347cde7 authored by Geoffrey Métais's avatar Geoffrey Métais

Prevent segfaults

parent e24e7856
......@@ -644,6 +644,8 @@ getMediaLongMetadata(JNIEnv* env, jobject thiz, jobject medialibrary, jlong id,
{
AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, medialibrary);
medialibrary::MediaPtr media = aml->media(id);
if (media == nullptr)
return 0L;
const medialibrary::IMediaMetadata& metadata = media->metadata((medialibrary::IMedia::MetadataType)metadataType);
return metadata.isSet() ? metadata.integer() : 0L;
}
......@@ -653,6 +655,8 @@ getMediaStringMetadata(JNIEnv* env, jobject thiz, jobject medialibrary, jlong id
{
AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, medialibrary);
medialibrary::MediaPtr media = aml->media(id);
if (media == nullptr)
return 0L;
const medialibrary::IMediaMetadata& metadata = media->metadata((medialibrary::IMedia::MetadataType)metadataType);
return metadata.isSet() ? env->NewStringUTF(metadata.str().c_str()) : nullptr;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment