summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorYuanQY <yuanqingyun@gmail.com>2013-02-22 19:51:05 +0800
committerGerrit Code Review <gerrit@cyanogenmod.org>2013-03-24 15:27:08 -0700
commit6e0d2a6e0ce70073f977844200f477b9c552a11e (patch)
tree7db31cec08ff439861e6b5e6fc263f0cb24cf87d /media
parent7d0a8e3019352e1a2f1147b23abc7989bf695243 (diff)
downloadframeworks_base-6e0d2a6e0ce70073f977844200f477b9c552a11e.zip
frameworks_base-6e0d2a6e0ce70073f977844200f477b9c552a11e.tar.gz
frameworks_base-6e0d2a6e0ce70073f977844200f477b9c552a11e.tar.bz2
Fix resource leak: When call MediaMetadataRetriever.setDataSource or getFrameAtTime should ensure call release in finally to avoid resource leak
Patch set 2: Remove unnecessary white spaces Change-Id: I49a7f2fb99dc8b9560e7c17421125356e45a87ac
Diffstat (limited to 'media')
-rwxr-xr-xmedia/java/android/media/videoeditor/VideoEditorImpl.java18
1 files changed, 14 insertions, 4 deletions
diff --git a/media/java/android/media/videoeditor/VideoEditorImpl.java b/media/java/android/media/videoeditor/VideoEditorImpl.java
index 2446c2f..0953050 100755
--- a/media/java/android/media/videoeditor/VideoEditorImpl.java
+++ b/media/java/android/media/videoeditor/VideoEditorImpl.java
@@ -1834,10 +1834,20 @@ public class VideoEditorImpl implements VideoEditor {
String filename = mI.getFilename();
if (mI instanceof MediaVideoItem) {
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
- retriever.setDataSource(filename);
- Bitmap bitmap = retriever.getFrameAtTime();
- retriever.release();
- retriever = null;
+ Bitmap bitmap = null;
+ try {
+ retriever.setDataSource(filename);
+ bitmap = retriever.getFrameAtTime();
+ } catch (RuntimeException ex) {
+ // Ignore failures while cleaning up.
+ } finally {
+ try {
+ retriever.release();
+ } catch (RuntimeException ex) {
+ // Ignore failures while cleaning up.
+ }
+ }
+
if (bitmap == null) {
String msg = "Thumbnail extraction from " +
filename + " failed";