Fix double free when the mesh contains duplicate bones.
parent
020554e213
commit
945c77d699
|
@ -59,6 +59,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/types.h>
|
#include <assimp/types.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -872,11 +874,15 @@ struct aiMesh {
|
||||||
|
|
||||||
// DO NOT REMOVE THIS ADDITIONAL CHECK
|
// DO NOT REMOVE THIS ADDITIONAL CHECK
|
||||||
if (mNumBones && mBones) {
|
if (mNumBones && mBones) {
|
||||||
|
std::unordered_set<const aiBone *> bones;
|
||||||
for (unsigned int a = 0; a < mNumBones; a++) {
|
for (unsigned int a = 0; a < mNumBones; a++) {
|
||||||
if (mBones[a]) {
|
if (mBones[a]) {
|
||||||
delete mBones[a];
|
bones.insert(mBones[a]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (const aiBone *bone: bones) {
|
||||||
|
delete bone;
|
||||||
|
}
|
||||||
delete[] mBones;
|
delete[] mBones;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue