From 635153b3a4d5e203e446f0b1f547365f7c2769c4 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 22 Dec 2021 21:08:28 +0100 Subject: [PATCH] LWS-Import: Avoid access to empty string token - Fix invalid access to string pointer when string token is empty - closes https://github.com/assimp/assimp/issues/4222 --- code/AssetLib/LWS/LWSLoader.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/AssetLib/LWS/LWSLoader.cpp b/code/AssetLib/LWS/LWSLoader.cpp index cb07787fa..cf04579b0 100644 --- a/code/AssetLib/LWS/LWSLoader.cpp +++ b/code/AssetLib/LWS/LWSLoader.cpp @@ -537,6 +537,11 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy // get file format version and print to log ++it; + + if ((*it).tokens[0].empty()) { + ASSIMP_LOG_ERROR("Invalid LWS file detectedm abort import."); + return; + } unsigned int version = strtoul10((*it).tokens[0].c_str()); ASSIMP_LOG_INFO("LWS file format version is ", (*it).tokens[0]); first = 0.;