Skip to content

[GEN][ZH] Prevent dereferencing NULL pointer 'tex' in WW3DAssetManager::Get_Texture() #1089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Generals/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,12 @@ TextureClass * WW3DAssetManager::Get_Texture
{
tex = NEW_REF (TextureClass, (lower_case_name, NULL, mip_level_count, texture_format, allow_compression));
}
else
{
WWASSERT_PRINT(false, ("Unhandled case"));
return NULL;
}

TextureHash.Insert(tex->Get_Texture_Name(),tex);
}

Expand Down
6 changes: 6 additions & 0 deletions GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,12 @@ TextureClass * WW3DAssetManager::Get_Texture
{
tex = NEW_REF (VolumeTextureClass, (lower_case_name, NULL, mip_level_count, texture_format, allow_compression, allow_reduction));
}
else

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps a switch statement would be better here, but it's not important and not the focus of this PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes if that assert starts hitting and we need more cases to handle then we can refactor that.

{
WWASSERT_PRINT(false, ("Unhandled case"));
return NULL;
}

TextureHash.Insert(tex->Get_Texture_Name(),tex);
}

Expand Down
Loading