Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
If malloc fails, prevent getting Segmentation Fault
Browse files Browse the repository at this point in the history
When the memory is limited for the process, malloc fails, and data is null. Hence, it creates Segmentation Fault by trying to write a null pointer.
  • Loading branch information
tcak committed Apr 6, 2016
1 parent a833234 commit d4f88a0
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/rt/tlsgc.d
Expand Up @@ -32,6 +32,7 @@ struct Data
void* init()
{
auto data = cast(Data*).malloc(Data.sizeof);
if( data is null ) return null;
*data = Data.init;

// do module specific initialization
Expand Down

0 comments on commit d4f88a0

Please sign in to comment.