Compare commits

...

1 Commits

Author SHA1 Message Date
Kim Kulling fef9fbea7c Add checks for invalid buffer ans size 2024-05-13 08:42:28 +02:00
2 changed files with 16 additions and 2 deletions

View File

@ -233,8 +233,13 @@ const aiScene *aiImportFileFromMemoryWithProperties(
unsigned int pFlags,
const char *pHint,
const aiPropertyStore *props) {
ai_assert(nullptr != pBuffer);
ai_assert(0 != pLength);
if (pBuffer == nullptr) {
return nullptr;
}
if (pLength == 0u) {
return nullptr;
}
const aiScene *scene = nullptr;
ASSIMP_BEGIN_EXCEPTION_REGION();

View File

@ -60,3 +60,12 @@ TEST_F( AssimpAPITest, aiGetLastErrorTest ) {
const char *error = aiGetErrorString();
EXPECT_NE(nullptr, error);
}
TEST_F(AssimpAPITest, aiImportFileFromMemoryTest) {
const aiScene *scene_null_buffer = aiImportFileFromMemory(nullptr, 0u, 0u, nullptr);
EXPECT_EQ(nullptr, scene_null_buffer);
char buffer[1024] = {'\0'};
const aiScene *scene_null_size = aiImportFileFromMemory(buffer, 0u, 0u, nullptr);
EXPECT_EQ(nullptr, scene_null_size);
}