From b5ca231cdf17bbe01c482ff18f3ce948d4be6d30 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Fri, 3 Jun 2016 16:55:01 -0700 Subject: [PATCH] fix(library/vm/vm): problems detected when using valgrind --- src/library/vm/vm.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/library/vm/vm.cpp b/src/library/vm/vm.cpp index f2fab873d3..441ebd461e 100644 --- a/src/library/vm/vm.cpp +++ b/src/library/vm/vm.cpp @@ -317,6 +317,7 @@ vm_instr mk_cases2_instr(unsigned pc1, unsigned pc2) { vm_instr mk_casesn_instr(unsigned num_pc, unsigned const * pcs) { lean_assert(num_pc >= 2); vm_instr r(opcode::CasesN); + r.m_cases_idx = 0; /* not really needed, but it avoids a valgrind warning. */ r.m_npcs = new unsigned[num_pc + 1]; r.m_npcs[0] = num_pc; for (unsigned i = 0; i < num_pc; i++) @@ -384,7 +385,7 @@ void vm_instr::copy_args(vm_instr const & i) { case opcode::CasesN: case opcode::BuiltinCases: m_npcs = new unsigned[i.m_npcs[0] + 1]; - for (unsigned j = 0; j < m_npcs[0] + 1; j++) + for (unsigned j = 0; j < i.m_npcs[0] + 1; j++) m_npcs[j] = i.m_npcs[j]; m_cases_idx = i.m_cases_idx; break;