From 74f1cc1ec4edea9b3f24878a8eeaf79389208002 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 6 Jul 2016 11:36:47 +0100 Subject: [PATCH] Improved casting to address crashes when handling classes that use virtual inheritance. --- include/osgDB/Serializer | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/osgDB/Serializer b/include/osgDB/Serializer index d1b91ae56..87c55ef68 100644 --- a/include/osgDB/Serializer +++ b/include/osgDB/Serializer @@ -551,8 +551,8 @@ public: ParentType::setUsage( _getter!=0, _setter!=0); } - virtual bool set(osg::Object& obj, void* value) { C& object = OBJECT_CAST(obj); (object.*_setter)( *(reinterpret_cast(value)) ); return true; } - virtual bool get(const osg::Object& obj, void* value) { const C& object = OBJECT_CAST(obj);*(reinterpret_cast(value )) = (object.*_getter)(); return true; } + virtual bool set(osg::Object& obj, void* value) { C& object = OBJECT_CAST(obj); (object.*_setter)( dynamic_cast(*(reinterpret_cast(value))) ); return true; } + virtual bool get(const osg::Object& obj, void* value) { const C& object = OBJECT_CAST(obj);*(reinterpret_cast(value )) = dynamic_cast((object.*_getter)()); return true; } virtual bool read( InputStream& is, osg::Object& obj ) {