config: Make config_alloc() no longer crash if allocation fails

This commit is contained in:
Jan Ekström 2014-01-31 17:30:27 +02:00
parent 7db28fad84
commit 007986974a

View file

@ -35,6 +35,11 @@
config *config_alloc() config *config_alloc()
{ {
config *cfg = (config *)malloc(sizeof(config)); config *cfg = (config *)malloc(sizeof(config));
if (!cfg) {
fprintf(stderr, "Failed to allocate a config object!\n");
return cfg;
}
memset(cfg, 0, sizeof(config)); memset(cfg, 0, sizeof(config));
return cfg; return cfg;
} }