Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e658d330 authored by Frederick Mayle's avatar Frederick Mayle
Browse files

binder: Don't use reinterpret_cast to down cast

In general, reinterpret_cast could do the wrong thing, e.g. if a class
derived from Parcelable and added more virtual methods, then the
pointer value needs to be adjusted when down casting.

Test: TH
Change-Id: I0d808cafa7501e9d03b83a03d1de9219bc672912
parent 9146157b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ public:
                *ret = nullptr;
                return android::BAD_VALUE;
            }
            *ret = std::shared_ptr<T>(mParcelable, reinterpret_cast<T*>(mParcelable.get()));
            *ret = std::static_pointer_cast<T>(mParcelable);
            return android::OK;
        }
        this->mParcelPtr->setDataPosition(0);
@@ -105,7 +105,7 @@ public:
            return status;
        }
        this->mParcelPtr = nullptr;
        *ret = std::shared_ptr<T>(mParcelable, reinterpret_cast<T*>(mParcelable.get()));
        *ret = std::static_pointer_cast<T>(mParcelable);
        return android::OK;
    }