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 23, 2018
1 parent 1e4afd5 commit 7fceae9
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 @@ -560,6 +560,7 @@ int MXExecutorReshape(int partial_shaping,
ExecutorHandle *out) {
MXAPIThreadLocalEntry *ret = MXAPIThreadLocalStore::Get();
API_BEGIN();
*out = nullptr; // ensure we can know whether to free executor on early abort
// create shape map for in_args and aux_states
std::unordered_map<std::string, TShape> kwargs(num_provided_arg_shapes);
for (mx_uint i = 0; i < num_provided_arg_shapes; ++i) {
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 7fceae9

Please sign in to comment.