commit b1c67dd920c94c96950782218686bc35d60ffc49
parent b3c449fa29812e728286b6461bf55f872cd891fb
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Mon, 28 Jan 2019 10:59:13 +0100
Fix a crash when args are just '-h' or invalid
Diffstat:
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/main.c b/src/main.c
@@ -30,7 +30,9 @@ int main(int argc, char** argv){
exit:
stardis_release(&stardis);
- if((memsz = MEM_ALLOCATED_SIZE(&stardis.allocator)) != 0) {
+ if(stardis.allocator_initialized
+ && (memsz = MEM_ALLOCATED_SIZE(&stardis.allocator)) != 0)
+ {
char dump[4096] = { '\0' };
MEM_DUMP(&stardis.allocator, dump, sizeof(dump));
fprintf(stderr, "%s\n", dump);
diff --git a/src/stardis-app.h b/src/stardis-app.h
@@ -779,9 +779,10 @@ struct stardis {
double radiative_temp[2];
struct camera camera;
struct mem_allocator allocator;
+ int allocator_initialized;
};
#define NULL_ALLOCATOR__ {NULL}
-#define NULL_STARDIS__ {NULL_GEOMETRY__, NULL, 0, 0, {0,0,0,0}, 0, {300,300}, NULL_CAMERA__, NULL_ALLOCATOR__}
+#define NULL_STARDIS__ {NULL_GEOMETRY__, NULL, 0, 0, {0,0,0,0}, 0, {300,300}, NULL_CAMERA__, NULL_ALLOCATOR__, 0}
static const struct stardis NULL_STARDIS = NULL_STARDIS__;
extern res_T