Add checks for invalid buffer ans size (#5570)
parent
47dbabadcd
commit
325b0a543f
|
@ -233,8 +233,13 @@ const aiScene *aiImportFileFromMemoryWithProperties(
|
||||||
unsigned int pFlags,
|
unsigned int pFlags,
|
||||||
const char *pHint,
|
const char *pHint,
|
||||||
const aiPropertyStore *props) {
|
const aiPropertyStore *props) {
|
||||||
ai_assert(nullptr != pBuffer);
|
if (pBuffer == nullptr) {
|
||||||
ai_assert(0 != pLength);
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pLength == 0u) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
const aiScene *scene = nullptr;
|
const aiScene *scene = nullptr;
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
|
|
|
@ -60,3 +60,12 @@ TEST_F( AssimpAPITest, aiGetLastErrorTest ) {
|
||||||
const char *error = aiGetErrorString();
|
const char *error = aiGetErrorString();
|
||||||
EXPECT_NE(nullptr, error);
|
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