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:
X512
2025-09-23 01:54:28 +00:00
committed by waddlesplash
parent db179db57b
commit b6f74b4905
5 changed files with 33 additions and 8 deletions
+3
View File
@@ -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)); }
+6
View File
@@ -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));
+16
View File
@@ -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)
{