From a7306abcfefbc2aff140c4bb9eda8ce88d31e243 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 31 Aug 2018 19:29:17 +0200 Subject: [PATCH] MDC-Loader: fix a possible nullptr access. --- CMakeLists.txt | 6 +++--- code/MDCLoader.cpp | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1fb717419..3d6037259 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,9 +111,9 @@ OPTION( INJECT_DEBUG_POSTFIX ) IF (IOS) - IF (NOT CMAKE_BUILD_TYPE) - SET(CMAKE_BUILD_TYPE "Release") - ENDIF (NOT CMAKE_BUILD_TYPE) + IF (NOT CMAKE_BUILD_TYPE) + SET(CMAKE_BUILD_TYPE "Release") + ENDIF (NOT CMAKE_BUILD_TYPE) ENDIF (IOS) # Use subset of Windows.h diff --git a/code/MDCLoader.cpp b/code/MDCLoader.cpp index e294a1912..03b3336de 100644 --- a/code/MDCLoader.cpp +++ b/code/MDCLoader.cpp @@ -434,10 +434,12 @@ void MDCImporter::InternReadFile( else if (1 == pScene->mNumMeshes) { pScene->mRootNode = new aiNode(); - pScene->mRootNode->mName = pScene->mMeshes[0]->mName; - pScene->mRootNode->mNumMeshes = 1; - pScene->mRootNode->mMeshes = new unsigned int[1]; - pScene->mRootNode->mMeshes[0] = 0; + if ( nullptr != pScene->mMeshes[0] ) { + pScene->mRootNode->mName = pScene->mMeshes[0]->mName; + pScene->mRootNode->mNumMeshes = 1; + pScene->mRootNode->mMeshes = new unsigned int[1]; + pScene->mRootNode->mMeshes[0] = 0; + } } else {