[Android] MediaDatabase: prevent a crash

Edward Wang git at videolan.org
Fri May 30 05:50:40 CEST 2014


vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Thu May 29 20:41:32 2014 -0400| [e3261ac25a491e178b33e21ac0576a22ca9535fc] | committer: Edward Wang

MediaDatabase: prevent a crash

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=e3261ac25a491e178b33e21ac0576a22ca9535fc
---

 vlc-android/src/org/videolan/vlc/MediaDatabase.java |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/MediaDatabase.java b/vlc-android/src/org/videolan/vlc/MediaDatabase.java
index a00644a..fb15a62 100644
--- a/vlc-android/src/org/videolan/vlc/MediaDatabase.java
+++ b/vlc-android/src/org/videolan/vlc/MediaDatabase.java
@@ -499,8 +499,13 @@ public class MediaDatabase {
         if (cursor.moveToFirst()) {
             blob = cursor.getBlob(0);
             if (blob != null && blob.length > 1 && blob.length < 500000) {
-                picture = BitmapFactory.decodeByteArray(blob, 0, blob.length);
-                blob = null;
+                try {
+                    picture = BitmapFactory.decodeByteArray(blob, 0, blob.length);
+                } catch(OutOfMemoryError e) {
+                    picture = null;
+                } finally {
+                    blob = null;
+                }
             }
         }
         cursor.close();



More information about the Android mailing list