From 472ee416b960eed639ca4f5bba6d250180eed3f0 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sun, 14 Aug 2016 17:11:42 +0200 Subject: Fix segfault after ^ --- bfcomp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bfcomp.c b/bfcomp.c index 8065fc4..5a3ede6 100644 --- a/bfcomp.c +++ b/bfcomp.c @@ -327,9 +327,11 @@ void readsource(FILE *f,char **sourcep,Sourcemap **smp){ sz*=2; source=realloc(source,sz); if(!source)outofmem(); - sm->maps=realloc(sm->maps,sz*sizeof(Range)); - if(!sm->maps)outofmem(); - memset(sm->maps+sz/2,0,sz/2*sizeof(Range)); + if(sm){ + sm->maps=realloc(sm->maps,sz*sizeof(Range)); + if(!sm->maps)outofmem(); + memset(sm->maps+sz/2,0,sz/2*sizeof(Range)); + } } char c=fgetc(f); if(feof(f))break; -- cgit v1.2.3-70-g09d2