From c33824dedc91ddc92d5bf49339ff0cab7f4d6f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 29 Jan 2015 12:45:12 +0100 Subject: Close input and output ParcelFileDescriptors properly also in error case --- src/org/openintents/openpgp/util/OpenPgpApi.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/org/openintents/openpgp/util/OpenPgpApi.java b/src/org/openintents/openpgp/util/OpenPgpApi.java index 9f51851..dbfb797 100644 --- a/src/org/openintents/openpgp/util/OpenPgpApi.java +++ b/src/org/openintents/openpgp/util/OpenPgpApi.java @@ -291,6 +291,14 @@ public class OpenPgpApi { } } + /** + * InputStream and OutputStreams are always closed after operating on them! + * + * @param data + * @param is + * @param os + * @return + */ public Intent executeApi(Intent data, InputStream is, OutputStream os) { ParcelFileDescriptor input = null; ParcelFileDescriptor output = null; @@ -349,7 +357,13 @@ public class OpenPgpApi { Log.e(OpenPgpApi.TAG, "IOException when closing ParcelFileDescriptor!", e); } } - // TODO: close input? Maybe the client wants to still use the input stream + if (input != null) { + try { + input.close(); + } catch (IOException e) { + Log.e(OpenPgpApi.TAG, "IOException when closing ParcelFileDescriptor!", e); + } + } } } -- cgit v1.2.3