summaryrefslogtreecommitdiffstats
path: root/media/mtp/MtpServer.h
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2011-04-25 12:56:21 -0700
committerMike Lockwood <lockwood@android.com>2011-04-25 13:36:11 -0700
commitc3f16e5620c090aeb75c0836572a8b913a4ef864 (patch)
treea888617667df3f7deb35d7123f8963ef23e9ed96 /media/mtp/MtpServer.h
parentc5182e31b23dc381d21ef43b7f7d682ffc54bd79 (diff)
downloadframeworks_av-c3f16e5620c090aeb75c0836572a8b913a4ef864.zip
frameworks_av-c3f16e5620c090aeb75c0836572a8b913a4ef864.tar.gz
frameworks_av-c3f16e5620c090aeb75c0836572a8b913a4ef864.tar.bz2
MTP: Fix file descriptor leak in file editing extensions
Change-Id: I6d0de5efe705d8060bbfd526c6880dc995a3aa30 Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'media/mtp/MtpServer.h')
-rw-r--r--media/mtp/MtpServer.h22
1 files changed, 16 insertions, 6 deletions
diff --git a/media/mtp/MtpServer.h b/media/mtp/MtpServer.h
index 35a38e7..b06eb28 100644
--- a/media/mtp/MtpServer.h
+++ b/media/mtp/MtpServer.h
@@ -67,12 +67,22 @@ private:
// represents an MTP object that is being edited using the android extensions
// for direct editing (BeginEditObject, SendPartialObject, TruncateObject and EndEditObject)
- struct ObjectEdit {
- MtpObjectHandle handle;
- MtpString path;
- uint64_t size;
- MtpObjectFormat format;
- int fd;
+ class ObjectEdit {
+ public:
+ MtpObjectHandle mHandle;
+ MtpString mPath;
+ uint64_t mSize;
+ MtpObjectFormat mFormat;
+ int mFD;
+
+ ObjectEdit(MtpObjectHandle handle, const char* path, uint64_t size,
+ MtpObjectFormat format, int fd)
+ : mHandle(handle), mPath(path), mSize(size), mFormat(format), mFD(fd) {
+ }
+
+ virtual ~ObjectEdit() {
+ close(mFD);
+ }
};
Vector<ObjectEdit*> mObjectEditList;