AMFImporter: make test against nullptr dereferencing meaningful.

pull/1259/head
Kim Kulling 2017-05-09 21:03:20 +02:00
parent f77e27ca19
commit 4a5c483ac4
1 changed files with 13 additions and 14 deletions

View File

@ -261,20 +261,19 @@ size_t AMFImporter::PostprocessHelper_GetTextureID_Or_Create(const std::string&
size_t off_b = 0;
// Calculate size of the target array and rule how data will be copied.
if ( nullptr != src_texture ) {
if(!pID_R.empty()) {
if(!pID_R.empty() && nullptr != src_texture[ 0 ] ) {
tex_size += src_texture[0]->Data.size(); step++, off_g++, off_b++;
}
if(!pID_G.empty()) {
if(!pID_G.empty() && nullptr != src_texture[ 1 ] ) {
tex_size += src_texture[1]->Data.size(); step++, off_b++;
}
if(!pID_B.empty()) {
if(!pID_B.empty() && nullptr != src_texture[ 2 ] ) {
tex_size += src_texture[2]->Data.size(); step++;
}
if(!pID_A.empty()) {
if(!pID_A.empty() && nullptr != src_texture[ 3 ] ) {
tex_size += src_texture[3]->Data.size(); step++;
}
}
// Create target array.
converted_texture.Data = new uint8_t[tex_size];
// And copy data