diff --git a/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.cpp b/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.cpp index 4722a2c6..ed288eb2 100644 --- a/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.cpp +++ b/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.cpp @@ -660,7 +660,7 @@ namespace skyline::service::hosbinder { } case TransactionCode::CancelBuffer: { - CancelBuffer(in.Pop(), in.Pop()); + CancelBuffer(in.Pop(), in.PopFlattenable()); break; } diff --git a/app/src/main/cpp/skyline/services/hosbinder/parcel.h b/app/src/main/cpp/skyline/services/hosbinder/parcel.h index ade71b28..af76ade7 100644 --- a/app/src/main/cpp/skyline/services/hosbinder/parcel.h +++ b/app/src/main/cpp/skyline/services/hosbinder/parcel.h @@ -49,20 +49,27 @@ namespace skyline::service::hosbinder { return value; } + /** + * @return A reference to an item from the top of data + */ + template + ValueType &PopFlattenable() { + auto size{Pop()}; + if (size != sizeof(ValueType)) + throw exception("Popping flattenable of size 0x{:X} with type size 0x{:X}", size, sizeof(ValueType)); + return Pop(); + } + /** * @return A pointer to an optional flattenable from the top of data, nullptr will be returned if the object doesn't exist */ template ValueType *PopOptionalFlattenable() { bool hasObject{Pop() != 0}; - if (hasObject) { - auto size{Pop()}; - if (size != sizeof(ValueType)) - throw exception("Popping flattenable of size 0x{:X} with type size 0x{:X}", size, sizeof(ValueType)); - return &Pop(); - } else { + if (hasObject) + return &PopFlattenable(); + else return nullptr; - } } template