diff options
author | harvey_tsai <harvey_tsai@htc.com> | 2015-06-11 11:51:36 +0800 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-12-19 22:11:40 -0500 |
commit | 9547f28464cb5470236c4e8d8d15cc2e4b46f4ed (patch) | |
tree | 3483dd8cfcc6c9710722ac636719e6aa8ed5faa2 /media | |
parent | dc84262be4a8b96e8537c6be0bd3c21d0b88705c (diff) | |
download | frameworks_base-9547f28464cb5470236c4e8d8d15cc2e4b46f4ed.zip frameworks_base-9547f28464cb5470236c4e8d8d15cc2e4b46f4ed.tar.gz frameworks_base-9547f28464cb5470236c4e8d8d15cc2e4b46f4ed.tar.bz2 |
Fix filedescriptor leakage in MediaMetadataRetriever
setDataSource(String) throws an IllegalArgumentException
when an IOException or FileNotFoundException occurs, but doesn't
close FileDescriptor accordingly.
Change-Id: Ib6e0f1418afeeb19e03abd4bedb4cc845a58b6b4
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/MediaMetadataRetriever.java | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/media/java/android/media/MediaMetadataRetriever.java b/media/java/android/media/MediaMetadataRetriever.java index a3ff080..7dd70d4 100644 --- a/media/java/android/media/MediaMetadataRetriever.java +++ b/media/java/android/media/MediaMetadataRetriever.java @@ -64,9 +64,7 @@ public class MediaMetadataRetriever throw new IllegalArgumentException(); } - FileInputStream is = null; - try { - is = new FileInputStream(path); + try (FileInputStream is = new FileInputStream(path)) { FileDescriptor fd = is.getFD(); setDataSource(fd, 0, 0x7ffffffffffffffL); } catch (FileNotFoundException fileEx) { @@ -74,12 +72,6 @@ public class MediaMetadataRetriever } catch (IOException ioEx) { throw new IllegalArgumentException(); } - - try { - if (is != null) { - is.close(); - } - } catch (Exception e) {} } /** |