Skip to content

Commit

Permalink
Fixed a stability issue of ParcelableHolder
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Kim committed Sep 29, 2024
1 parent cf36bbf commit 35e8b4c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 6 additions & 3 deletions rsbinder/src/parcelable_holder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl Deserialize for ParcelableHolder {
log::error!("ParcelableHolder::deserialize: unexpected null");
Err(StatusCode::UnexpectedNull)
} else {
let mut parcelable = ParcelableHolder::new(Default::default());
let mut parcelable = ParcelableHolder::default();
parcelable.read_from_parcel(parcel)?;
Ok(parcelable)
}
Expand Down Expand Up @@ -250,8 +250,11 @@ impl Parcelable for ParcelableHolder {
}

fn read_from_parcel(&mut self, parcel: &mut Parcel) -> Result<()> {
if self.stability as i32 != parcel.read::<i32>()? {
log::error!("ParcelableHolder::read_from_parcel: parcelable stability mismatch");
let wire_stability: i32 = parcel.read()?;
if self.stability as i32 != wire_stability {
log::error!("ParcelableHolder::read_from_parcel: parcelable stability mismatch: {:?} != {:?}",
self.stability, wire_stability);

return Err(StatusCode::BadValue);
}

Expand Down
1 change: 0 additions & 1 deletion tests/src/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,6 @@ fn test_parcelable() {
}

#[test]
#[ignore]
fn test_repeat_extendable_parcelable() {
let service = get_test_service();

Expand Down

0 comments on commit 35e8b4c

Please sign in to comment.