diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp index 1d126d3a8bd..10165d5cd43 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp @@ -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(); } diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp index a0cbd3dba88..1a7e00c3a88 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp @@ -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(); }