From 10ec58703fb882402b75efee76f5d009f40ff1a0 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sat, 18 May 2013 21:22:44 +0100 Subject: [PATCH] Fix vvp memory leak for VPI call with no calltf. If a VPI call with real arguments has no calltf function, we still need to pop the arguments off the vthread stack. Similarly, if it has a real result, we need to push a value onto the vthread stack. --- vvp/vpi_tasks.cc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/vvp/vpi_tasks.cc b/vvp/vpi_tasks.cc index 5060f648f..90310b38b 100644 --- a/vvp/vpi_tasks.cc +++ b/vvp/vpi_tasks.cc @@ -911,17 +911,16 @@ void vpip_execute_vpi_call(vthread_t thr, vpiHandle ref) } vpi_put_value(ref, &val, 0, vpiNoDelay); } + } + if (vpip_cur_task->real_stack > 0) + vthread_pop_real(thr, vpip_cur_task->real_stack); + if (vpip_cur_task->string_stack > 0) + vthread_pop_str(thr, vpip_cur_task->string_stack); - if (vpip_cur_task->real_stack > 0) - vthread_pop_real(thr, vpip_cur_task->real_stack); - if (vpip_cur_task->string_stack > 0) - vthread_pop_str(thr, vpip_cur_task->string_stack); - - /* If the function has a real value, then push the value - to the thread stack. */ - if (sysfunc_real*func_real = dynamic_cast(ref)) { - vthread_push_real(thr, func_real->return_value_); - } + /* If the function has a real value, then push the value + to the thread stack. */ + if (sysfunc_real*func_real = dynamic_cast(ref)) { + vthread_push_real(thr, func_real->return_value_); } }