From bc4afde167513f7efe76012015f9fa3641c156cf Mon Sep 17 00:00:00 2001 From: Rebecca Schultz Zavin Date: Fri, 13 Feb 2009 16:34:38 -0800 Subject: Need to dup file descriptor when reading from the binder for native handles When reading a native handle that has passed through the binder, the fds have to be duped to prevent them from getting closed when the binder object is destructed. Signed-off-by: Rebecca Schultz Zavin --- libs/utils/Parcel.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libs/utils/Parcel.cpp') diff --git a/libs/utils/Parcel.cpp b/libs/utils/Parcel.cpp index 0eba0b07c8d4..2962b25aeae2 100644 --- a/libs/utils/Parcel.cpp +++ b/libs/utils/Parcel.cpp @@ -945,14 +945,13 @@ native_handle* Parcel::readNativeHandle(native_handle* (*alloc)(void*, int, int) return 0; } } - for (int i=0 ; err==NO_ERROR && idata[i] = readFileDescriptor(); + h->data[i] = dup(readFileDescriptor()); if (h->data[i] < 0) err = BAD_VALUE; } - + err = read(h->data + numFds, sizeof(int)*numInts); - + if (err != NO_ERROR) { if (alloc == 0) { free(h); -- cgit v1.2.3-59-g8ed1b