am 2098517e: make sure Parcel handles 0-sized LightFlatenables

* commit '2098517e3e12a401005d7a7510d6c4943707b98d':
  make sure Parcel handles 0-sized LightFlatenables
This commit is contained in:
Mathias Agopian 2012-08-31 18:45:28 -07:00 committed by Android Git Automerger
commit df0adbbb60

View File

@ -285,9 +285,12 @@ status_t Parcel::write(const LightFlattenable<T>& 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<typename T>
@ -303,9 +306,12 @@ status_t Parcel::read(LightFlattenable<T>& 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;
}
// ---------------------------------------------------------------------------