From ad33fd78a50fc20fc1ff3f8df85f6c09c0a619a1 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Tue, 8 May 2018 10:53:02 +0200 Subject: [PATCH] BAffineTransform: de-virtualize some calls in flattening code The Flatten and Unflatten method should check the size according to the matching FlattenedSize method, not a possibly overriden version. May also fix #14128 since we avoid use of the vtable by doing this. --- src/kits/interface/AffineTransform.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/kits/interface/AffineTransform.cpp b/src/kits/interface/AffineTransform.cpp index 149435dda1..2bc72c9e38 100644 --- a/src/kits/interface/AffineTransform.cpp +++ b/src/kits/interface/AffineTransform.cpp @@ -98,7 +98,7 @@ BAffineTransform::FlattenedSize() const status_t BAffineTransform::Flatten(void* _buffer, ssize_t size) const { - if (_buffer == NULL || size < FlattenedSize()) + if (_buffer == NULL || size < BAffineTransform::FlattenedSize()) return B_BAD_VALUE; double* buffer = reinterpret_cast(_buffer); @@ -117,8 +117,10 @@ BAffineTransform::Flatten(void* _buffer, ssize_t size) const status_t BAffineTransform::Unflatten(type_code code, const void* _buffer, ssize_t size) { - if (_buffer == NULL || size < FlattenedSize() || code != TypeCode()) + if (_buffer == NULL || size < BAffineTransform::FlattenedSize() + || code != BAffineTransform::TypeCode()) { return B_BAD_VALUE; + } const double* buffer = reinterpret_cast(_buffer);