From 6a7ee816100ac22db06b22e76b353aef3dd261ee Mon Sep 17 00:00:00 2001 From: Alex Hirsch Date: Wed, 10 Mar 2021 19:09:41 +0100 Subject: [PATCH] Always dynamically allocate PropertyTable - `Texture::~Texture` expects `props` to be dynamically allocated. - `GetPropertyTable` returned a pointer to an existing `PropertyTable` but is expected to return a newly, dynamically allocated one. - `PropertyTable::PropertyTable()` suggests that an empty `element` property is valid. fix #46876 fix #45573 (cherry picked from commit 09bda3f140937aaf5e4f028f7f04656ca30c7e6b) --- modules/fbx/fbx_parser/FBXDocumentUtil.cpp | 2 +- modules/fbx/fbx_parser/FBXProperties.cpp | 5 +++++ modules/fbx/fbx_parser/FBXProperties.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/fbx/fbx_parser/FBXDocumentUtil.cpp b/modules/fbx/fbx_parser/FBXDocumentUtil.cpp index d17b083f472..3e186d7ef39 100644 --- a/modules/fbx/fbx_parser/FBXDocumentUtil.cpp +++ b/modules/fbx/fbx_parser/FBXDocumentUtil.cpp @@ -160,7 +160,7 @@ const PropertyTable *GetPropertyTable(const Document &doc, DOMWarning("property table (Properties70) not found", element); } if (templateProps) { - return templateProps; + return new const PropertyTable(templateProps); } else { return new const PropertyTable(); } diff --git a/modules/fbx/fbx_parser/FBXProperties.cpp b/modules/fbx/fbx_parser/FBXProperties.cpp index 2e220ca4ae4..62f2ba52d99 100644 --- a/modules/fbx/fbx_parser/FBXProperties.cpp +++ b/modules/fbx/fbx_parser/FBXProperties.cpp @@ -150,6 +150,11 @@ PropertyTable::PropertyTable() : templateProps(), element() { } +// ------------------------------------------------------------------------------------------------ +PropertyTable::PropertyTable(const PropertyTable *templateProps) : + templateProps(templateProps), element() { +} + // ------------------------------------------------------------------------------------------------ PropertyTable::PropertyTable(const ElementPtr element, const PropertyTable *templateProps) : templateProps(templateProps), element(element) { diff --git a/modules/fbx/fbx_parser/FBXProperties.h b/modules/fbx/fbx_parser/FBXProperties.h index ff22de1f455..92fabd3a96a 100644 --- a/modules/fbx/fbx_parser/FBXProperties.h +++ b/modules/fbx/fbx_parser/FBXProperties.h @@ -137,6 +137,7 @@ class PropertyTable { public: // in-memory property table with no source element PropertyTable(); + PropertyTable(const PropertyTable *templateProps); PropertyTable(const ElementPtr element, const PropertyTable *templateProps); ~PropertyTable();