Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Fix bad delete.
Browse files Browse the repository at this point in the history
Delete the pointed-to handle on cleanup, not the location of the handle itself. Also don't delete it if we didn't set it in the first place.
  • Loading branch information
Taliesin Beynon committed Nov 22, 2018
1 parent 1e4afd5 commit 73709fd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/c_api/c_api_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ int MXExecutorReshape(int partial_shaping,
std::vector<NDArray> arg_grad_vec;
std::vector<NDArray> aux_state_vec;

*out = nullptr;
Executor* exec = static_cast<Executor*>(shared_exec);
*out = exec->Reshape(partial_shaping, allow_up_sizing, ctx, ctx_map, kwargs,
&in_arg_vec, &arg_grad_vec, &aux_state_vec);
Expand Down Expand Up @@ -623,7 +624,7 @@ int MXExecutorReshape(int partial_shaping,
*aux_states = &(ret->ret_handles[nd_idx]);
nd_idx = ret->ret_handles.size();
}
API_END_HANDLE_ERROR(delete out);
API_END_HANDLE_ERROR(if (*out != nullptr) delete *out);
}

int MXExecutorGetOptimizedSymbol(ExecutorHandle handle,
Expand Down

0 comments on commit 73709fd

Please sign in to comment.