Permalink
Browse files

Fix use of uninitialised context pointer

  • Loading branch information...
1 parent 152f2f6 commit 761a856c289aa23b85b417530c22e19e1a07a94d @nickg committed Dec 23, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/cgen.c
View
@@ -2677,10 +2677,12 @@ static void cgen_process(tree_t t)
// Return to simulation kernel after initialisation
- LLVMValueRef state_ptr = LLVMBuildStructGEP(builder, ctx.state, 0, "");
+ LLVMValueRef state_ptr = LLVMBuildStructGEP(builder, ctx.state, 0, "");
+ LLVMValueRef context_ptr = LLVMBuildStructGEP(builder, ctx.state, 1, "");
cgen_sched_process(llvm_int64(0));
LLVMBuildStore(builder, llvm_int32(0 /* start */), state_ptr);
+ LLVMBuildStore(builder, LLVMConstNull(llvm_void_ptr()), context_ptr);
LLVMBuildRetVoid(builder);
// Sequential statements
@@ -3138,8 +3140,10 @@ static void cgen_proc_body(tree_t t)
LLVMPositionBuilderAtEnd(builder, init_bb);
- LLVMValueRef state_ptr = LLVMBuildStructGEP(builder, ctx.state, 0, "");
+ LLVMValueRef state_ptr = LLVMBuildStructGEP(builder, ctx.state, 0, "");
+ LLVMValueRef context_ptr = LLVMBuildStructGEP(builder, ctx.state, 1, "");
LLVMBuildStore(builder, llvm_int32(0 /* start */), state_ptr);
+ LLVMBuildStore(builder, LLVMConstNull(llvm_void_ptr()), context_ptr);
LLVMBuildBr(builder, start_bb);

0 comments on commit 761a856

Please sign in to comment.