Add checks for invalid buffer ans size (#5570)
parent
47dbabadcd
commit
325b0a543f
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue