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 <rebecca@android.com>
This commit is contained in:
parent
dccb00bd4c
commit
3fec108e6c
1 changed files with 2 additions and 3 deletions
|
@ -950,14 +950,13 @@ native_handle* Parcel::readNativeHandle(native_handle* (*alloc)(void*, int, int)
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0 ; err==NO_ERROR && i<numFds ; i++) {
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue