mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0024836: Stack overflow when raising exception in low memory condition
Standard_OutOfMemory exception is refactored so as to avoid memory allocations (which will likely fail) when it is raised: - method NewInstance() returns static instance (singleton) - method Raise() raises copy of that singleton, resetting its message string - message string is stored as field, not allocated dynamically (thus maximum message length is limited by buffer size) Class Standard_Failure slightly revised: method Destroy() is merged to destructor, methods Get/SetMessageString() are made virtual. Add test case for the bug
This commit is contained in:
@@ -73,7 +73,7 @@ void* NCollection_WinHeapAllocator::Allocate (const Standard_Size theSize)
|
||||
if (aResult == NULL)
|
||||
{
|
||||
char aBuf[128];
|
||||
Sprintf (aBuf, "Failed to allocate " PRIuPTR " bytes in local dynamic heap", theSize);
|
||||
Sprintf (aBuf, "Failed to allocate %" PRIuPTR " bytes in local dynamic heap", theSize);
|
||||
Standard_OutOfMemory::Raise (aBuf);
|
||||
}
|
||||
return aResult;
|
||||
|
Reference in New Issue
Block a user