Skip to content
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
14 changes: 12 additions & 2 deletions Generals/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1701,8 +1701,18 @@ PrototypeClass * WW3DAssetManager::Find_Prototype(const char * name)
PrototypeClass * test = PrototypeHashTable[hash];

while (test != NULL) {
if (stricmp(test->Get_Name(),name) == 0) {
return test;
// Defensive check: protect against accessing freed/invalid prototype pointers
// Use SEH to catch access violations from dangling pointers in the hash chain
__try {
const char* test_name = test->Get_Name();
if (test_name != NULL && stricmp(test_name, name) == 0) {
return test;
}
}
__except(EXCEPTION_EXECUTE_HANDLER) {
// Invalid pointer detected (use-after-free), stop traversing the chain
// This can happen if a prototype was deleted without being properly removed from the hash table
break;
}
test = test->friend_getNextHash();
}
Expand Down
14 changes: 12 additions & 2 deletions GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1678,8 +1678,18 @@ PrototypeClass * WW3DAssetManager::Find_Prototype(const char * name)
PrototypeClass * test = PrototypeHashTable[hash];

while (test != NULL) {
if (stricmp(test->Get_Name(),name) == 0) {
return test;
// Defensive check: protect against accessing freed/invalid prototype pointers
// Use SEH to catch access violations from dangling pointers in the hash chain
__try {
const char* test_name = test->Get_Name();
if (test_name != NULL && stricmp(test_name, name) == 0) {
return test;
}
}
__except(EXCEPTION_EXECUTE_HANDLER) {
// Invalid pointer detected (use-after-free), stop traversing the chain
// This can happen if a prototype was deleted without being properly removed from the hash table
break;
}
test = test->friend_getNextHash();
}
Expand Down
Loading