- Use MAP_FAILED error code for check whether mmap() was successful

- Replace various malloc() with Z_Malloc
- Fix several memory leaks when VM compilation failed and Com_Error is called
- Make failed mmap/VirtualAlloc/malloc calls fatal
This commit is contained in:
Thilo Schulz 2011-02-10 18:45:28 +00:00
parent 5e0d0efd2e
commit 544a1c0c1a
5 changed files with 50 additions and 27 deletions

View file

@ -1837,7 +1837,7 @@ PPC_ComputeCode( vm_t *vm )
unsigned char *dataAndCode = mmap( NULL, codeLength,
PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0 );
if ( ! dataAndCode )
if (dataAndCode == MAP_FAILED)
DIE( "Not enough memory" );
ppc_instruction_t *codeNow, *codeBegin;