app_server: do not pass BAffineTransform as-is over server link
BAffineTransform is not POD type and contains vtable. Reading it from byte stream as-is will cause vtable corruption. Change-Id: I1371444444ffa47f77a88f5f82b3fe6ea031b14c Reviewed-on: https://review.haiku-os.org/c/haiku/+/9660 Reviewed-by: waddlesplash <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#define _LINK_RECEIVER_H
|
||||
|
||||
|
||||
#include <AffineTransform.h>
|
||||
#include <OS.h>
|
||||
|
||||
|
||||
@@ -42,6 +43,8 @@ class LinkReceiver {
|
||||
status_t ReadRegion(BRegion* region);
|
||||
status_t ReadShape(BShape* shape);
|
||||
status_t ReadGradient(BGradient** gradient);
|
||||
status_t ReadAffineTransform(BAffineTransform *transform)
|
||||
{ return Read(&transform->sx, sizeof(double) * 6); }
|
||||
|
||||
template <class Type> status_t Read(Type *data)
|
||||
{ return Read(data, sizeof(Type)); }
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#define _LINK_SENDER_H
|
||||
|
||||
|
||||
#include <AffineTransform.h>
|
||||
#include <OS.h>
|
||||
|
||||
|
||||
@@ -43,6 +44,11 @@ class LinkSender {
|
||||
status_t AttachRegion(const BRegion& region);
|
||||
status_t AttachShape(BShape& shape);
|
||||
status_t AttachGradient(const BGradient& gradient);
|
||||
status_t AttachAffineTransform(const BAffineTransform& transform)
|
||||
{
|
||||
return Attach(&transform.sx, sizeof(double) * 6);
|
||||
}
|
||||
|
||||
template <class Type> status_t Attach(const Type& data)
|
||||
{
|
||||
return Attach(&data, sizeof(Type));
|
||||
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
status_t AttachRegion(const BRegion& region);
|
||||
status_t AttachShape(BShape& shape);
|
||||
status_t AttachGradient(const BGradient& gradient);
|
||||
status_t AttachAffineTransform(const BAffineTransform& transform);
|
||||
|
||||
template <class Type>
|
||||
status_t Attach(const Type& data);
|
||||
@@ -79,6 +80,7 @@ public:
|
||||
status_t ReadRegion(BRegion* region);
|
||||
status_t ReadShape(BShape* shape);
|
||||
status_t ReadGradient(BGradient** _gradient);
|
||||
status_t ReadAffineTransform(BAffineTransform* transform);
|
||||
|
||||
template <class Type>
|
||||
status_t Read(Type* data);
|
||||
@@ -189,6 +191,13 @@ ServerLink::AttachGradient(const BGradient& gradient)
|
||||
}
|
||||
|
||||
|
||||
inline status_t
|
||||
ServerLink::AttachAffineTransform(const BAffineTransform& transform)
|
||||
{
|
||||
return fSender->AttachAffineTransform(transform);
|
||||
}
|
||||
|
||||
|
||||
template<class Type> status_t
|
||||
ServerLink::Attach(const Type& data)
|
||||
{
|
||||
@@ -276,6 +285,13 @@ ServerLink::ReadGradient(BGradient** _gradient)
|
||||
}
|
||||
|
||||
|
||||
inline status_t
|
||||
ServerLink::ReadAffineTransform(BAffineTransform* transform)
|
||||
{
|
||||
return fReceiver->ReadAffineTransform(transform);
|
||||
}
|
||||
|
||||
|
||||
template <class Type> status_t
|
||||
ServerLink::Read(Type* data)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user