Commit 9fbbc2ee authored by Geoffrey Métais's avatar Geoffrey Métais

Prevent segfaults

parent 2cffffdf
...@@ -161,7 +161,9 @@ AndroidMediaLibrary::forceParserRetry() ...@@ -161,7 +161,9 @@ AndroidMediaLibrary::forceParserRetry()
bool bool
AndroidMediaLibrary::increasePlayCount(int64_t mediaId) AndroidMediaLibrary::increasePlayCount(int64_t mediaId)
{ {
return p_ml->media(mediaId)->increasePlayCount(); auto media = p_ml->media(mediaId);
if (media != nullptr)
return media->increasePlayCount();
} }
std::vector<medialibrary::MediaPtr> std::vector<medialibrary::MediaPtr>
......
...@@ -667,6 +667,8 @@ setMediaStringMetadata(JNIEnv* env, jobject thiz, jobject medialibrary, jlong id ...@@ -667,6 +667,8 @@ setMediaStringMetadata(JNIEnv* env, jobject thiz, jobject medialibrary, jlong id
AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, medialibrary); AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, medialibrary);
const char *char_meta = env->GetStringUTFChars(meta, JNI_FALSE); const char *char_meta = env->GetStringUTFChars(meta, JNI_FALSE);
medialibrary::MediaPtr media = aml->media(id); medialibrary::MediaPtr media = aml->media(id);
if (media == nullptr)
return;
media->setMetadata((medialibrary::IMedia::MetadataType)metadataType, char_meta); media->setMetadata((medialibrary::IMedia::MetadataType)metadataType, char_meta);
env->ReleaseStringUTFChars(meta, char_meta); env->ReleaseStringUTFChars(meta, char_meta);
} }
...@@ -676,6 +678,8 @@ setMediaLongMetadata(JNIEnv* env, jobject thiz, jobject medialibrary, jlong id, ...@@ -676,6 +678,8 @@ setMediaLongMetadata(JNIEnv* env, jobject thiz, jobject medialibrary, jlong id,
{ {
AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, medialibrary); AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, medialibrary);
medialibrary::MediaPtr media = aml->media(id); medialibrary::MediaPtr media = aml->media(id);
if (media == nullptr)
return;
media->setMetadata((medialibrary::IMedia::MetadataType)metadataType, meta); media->setMetadata((medialibrary::IMedia::MetadataType)metadataType, meta);
} }
......
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