1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0024834: Allocation of memory for exception message must not throw another exception

- Add QA draw command OCC24834
- Make functions allocate_message/deallocate_message use malloc/free instead of operator new/delete
- Eliminate compilation error on Linux

Test case for issue CR24834
This commit is contained in:
msv
2014-04-24 16:25:08 +04:00
committed by bugmaster
parent 86b03c9774
commit a73267f24b
3 changed files with 85 additions and 6 deletions

View File

@@ -25,13 +25,14 @@ static Standard_CString allocate_message(const Standard_CString AString)
Standard_CString aStr = 0;
if(AString) {
const Standard_Size aLen = strlen(AString);
aStr = new Standard_Character[aLen+sizeof(Standard_Integer)+1];
Standard_PCharacter pStr=(Standard_PCharacter)aStr;
strcpy(pStr+sizeof(Standard_Integer),AString);
*((Standard_Integer*)aStr) = 1;
aStr = (Standard_CString) malloc(aLen+sizeof(Standard_Integer)+1);
if (aStr) {
Standard_PCharacter pStr=(Standard_PCharacter)aStr;
strcpy(pStr+sizeof(Standard_Integer),AString);
*((Standard_Integer*)aStr) = 1;
}
}
return aStr;
}
static Standard_CString copy_message(Standard_CString aMessage)
@@ -49,7 +50,7 @@ static void deallocate_message(Standard_CString aMessage)
if(aMessage) {
(*((Standard_Integer*)aMessage))--;
if(*((Standard_Integer*)aMessage)==0)
delete [](Standard_PCharacter)aMessage;
free((void*)aMessage);
}
}