make sure Parcel handles 0-sized LightFlatenables

Change-Id: Ib30a1c0228f8a938abaa0c7c8a6ba32ffd971121
This commit is contained in:
Mathias Agopian 2012-08-31 14:25:22 -07:00
parent 8210185fe3
commit 2098517e3e

View File

@ -285,10 +285,13 @@ status_t Parcel::write(const LightFlattenable<T>& val) {
return err; return err;
} }
} }
if (size) {
void* buffer = writeInplace(size); void* buffer = writeInplace(size);
return buffer == NULL ? NO_MEMORY : return buffer == NULL ? NO_MEMORY :
val.flatten(buffer); val.flatten(buffer);
} }
return NO_ERROR;
}
template<typename T> template<typename T>
status_t Parcel::read(LightFlattenable<T>& val) const { status_t Parcel::read(LightFlattenable<T>& val) const {
@ -303,10 +306,13 @@ status_t Parcel::read(LightFlattenable<T>& val) const {
} }
size = s; size = s;
} }
if (size) {
void const* buffer = readInplace(size); void const* buffer = readInplace(size);
return buffer == NULL ? NO_MEMORY : return buffer == NULL ? NO_MEMORY :
val.unflatten(buffer, size); val.unflatten(buffer, size);
} }
return NO_ERROR;
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------