Fix garbage messages in SIB, MD2, and MDC loaders.

This commit is contained in:
Jason C
2021-05-04 21:24:44 -04:00
parent a9fb1e56ae
commit 9a04f5d4b0
3 changed files with 20 additions and 32 deletions

View File

@@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/DefaultLogger.hpp>
#include <assimp/IOSystem.hpp>
#include <assimp/Importer.hpp>
#include <assimp/StringUtils.h>
#include <memory>
@@ -143,16 +144,8 @@ void MDCImporter::ValidateHeader() {
if (pcHeader->ulIdent != AI_MDC_MAGIC_NUMBER_BE &&
pcHeader->ulIdent != AI_MDC_MAGIC_NUMBER_LE) {
char szBuffer[5];
szBuffer[0] = ((char *)&pcHeader->ulIdent)[0];
szBuffer[1] = ((char *)&pcHeader->ulIdent)[1];
szBuffer[2] = ((char *)&pcHeader->ulIdent)[2];
szBuffer[3] = ((char *)&pcHeader->ulIdent)[3];
szBuffer[4] = '\0';
throw DeadlyImportError("Invalid MDC magic word: should be IDPC, the "
"magic word found is " +
std::string(szBuffer));
throw DeadlyImportError("Invalid MDC magic word: expected IDPC, found ",
ai_str_toprintable((char *)&pcHeader->ulIdent, 4));
}
if (pcHeader->ulVersion != AI_MDC_VERSION) {