summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2016-08-14 17:11:42 +0200
committertomsmeding <tom.smeding@gmail.com>2016-08-14 17:11:42 +0200
commit472ee416b960eed639ca4f5bba6d250180eed3f0 (patch)
tree20fc1c631c441c8a3ce2deb971357dcdce7679f3
parenta7d52eef038d25b83ab7d7e8730749d877b6a73c (diff)
Fix segfault after ^
-rw-r--r--bfcomp.c8
1 files 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;