From 9e1eda90ff4c426750eed202c03808f6406988bb Mon Sep 17 00:00:00 2001 From: Joshua Allen Date: Wed, 8 Mar 2017 21:37:20 -0500 Subject: do not malloc if size is 0 --- src/survive_config.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/survive_config.c') diff --git a/src/survive_config.c b/src/survive_config.c index 38c24e1..3f0f199 100644 --- a/src/survive_config.c +++ b/src/survive_config.c @@ -31,9 +31,13 @@ void destroy_config_entry(config_entry* ce) { void init_config_group(config_group *cg, uint16_t count) { uint16_t i = 0; - cg->config_entries = malloc(count*sizeof(config_entry)); cg->used_entries = 0; cg->max_entries = count; + cg->config_entries = NULL; + + if (count==0) return; + + cg->config_entries = malloc(count*sizeof(config_entry)); for (i=0;iconfig_entries+i); -- cgit v1.2.3