From 9ea09757fa63ad2a9bea9c846b51c1210d69c79f Mon Sep 17 00:00:00 2001 From: Narayan Kamath Date: Wed, 8 Oct 2014 17:35:45 +0100 Subject: Fix broken error check in Parcel::readBlob mmap returns MAP_FAILED (which is -1) and not NULL on failure. Diagnosed by cferris. bug: 17909809 Change-Id: I609788ebf94742ef88af002d2d3f3bc9b9e520ac --- libs/binder/Parcel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libs') diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index f61eaca..1dbb06f 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -1281,7 +1281,7 @@ status_t Parcel::readBlob(size_t len, ReadableBlob* outBlob) const if (fd == int(BAD_TYPE)) return BAD_VALUE; void* ptr = ::mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0); - if (!ptr) return NO_MEMORY; + if (ptr == MAP_FAILED) return NO_MEMORY; outBlob->init(true /*mapped*/, ptr, len); return NO_ERROR; -- cgit v1.1