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; } // ---------------------------------------------------------------------------