From c9ee8c2dd7d0860b41a3312bbf7ff390f5d0cf8e Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Mon, 25 Apr 2011 12:56:21 -0700 Subject: DO NOT MERGE MTP: Fix file descriptor leak in file editing extensions Change-Id: Ie0b979b5cfd9b5f9e9196c5f8c8ecccef6ed84c3 Signed-off-by: Mike Lockwood --- media/mtp/MtpServer.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'media/mtp/MtpServer.h') 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 mObjectEditList; -- cgit v1.1