From 3fec108e6c2a90fbb1976f69407805ff653eb0e7 Mon Sep 17 00:00:00 2001 From: Rebecca Schultz Zavin Date: Fri, 13 Feb 2009 16:34:38 -0800 Subject: [PATCH] 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 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libs/utils/Parcel.cpp b/libs/utils/Parcel.cpp index 0f4b64730..4225e6728 100644 --- a/libs/utils/Parcel.cpp +++ b/libs/utils/Parcel.cpp @@ -950,14 +950,13 @@ native_handle* Parcel::readNativeHandle(native_handle* (*alloc)(void*, int, int) return 0; } } - for (int i=0 ; err==NO_ERROR && idata[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);