summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;