Skip to content
This repository was archived by the owner on Sep 7, 2022. It is now read-only.

Parcelable implementation bug #35

Open
MariaPet opened this issue Sep 13, 2016 · 0 comments
Open

Parcelable implementation bug #35

MariaPet opened this issue Sep 13, 2016 · 0 comments

Comments

@MariaPet
Copy link

Hello!
In the Beacon.java class, which implements Parcelable, the writeToParcel method writes these values in the beginning of it

@Override
public void writeToParcel(Parcel dest, int flags) {
    dest.writeString(type);
    dest.writeByteArray(id);
    dest.writeString(status);

while the class constructor from a Parcel source tries to read these values

private Beacon(Parcel source) {
    type = source.readString();
    int len = source.readInt();
    id = new byte[len];
    source.readByteArray(id);
    status = source.readString();

The len variable is read from the source as an int that was never set, and a NullPointer exception is caused when source.readByteArray(id); is invoked.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant