From 2098517e3e12a401005d7a7510d6c4943707b98d Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 31 Aug 2012 14:25:22 -0700 Subject: [PATCH] make sure Parcel handles 0-sized LightFlatenables Change-Id: Ib30a1c0228f8a938abaa0c7c8a6ba32ffd971121 --- include/binder/Parcel.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/include/binder/Parcel.h b/include/binder/Parcel.h index 877b17c2d..3ff95d282 100644 --- a/include/binder/Parcel.h +++ b/include/binder/Parcel.h @@ -285,9 +285,12 @@ status_t Parcel::write(const LightFlattenable& val) { return err; } } - void* buffer = writeInplace(size); - return buffer == NULL ? NO_MEMORY : - val.flatten(buffer); + if (size) { + void* buffer = writeInplace(size); + return buffer == NULL ? NO_MEMORY : + val.flatten(buffer); + } + return NO_ERROR; } template @@ -303,9 +306,12 @@ status_t Parcel::read(LightFlattenable& val) const { } size = s; } - void const* buffer = readInplace(size); - return buffer == NULL ? NO_MEMORY : - val.unflatten(buffer, size); + if (size) { + void const* buffer = readInplace(size); + return buffer == NULL ? NO_MEMORY : + val.unflatten(buffer, size); + } + return NO_ERROR; } // ---------------------------------------------------------------------------