Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null Pointer Access #51

Closed
funyarinpa01 opened this issue Jul 22, 2022 · 1 comment
Closed

Null Pointer Access #51

funyarinpa01 opened this issue Jul 22, 2022 · 1 comment

Comments

@funyarinpa01
Copy link

Accessing the smart pointer after it is moved does not make sense. This way if an exception is thrown in the try block the code will always fail.

// Run a single continuation
template<typename Sched>
void run_continuation(Sched& sched, task_ptr&& cont)
{
LIBASYNC_TRY {
detail::schedule_task(sched, std::move(cont));
} LIBASYNC_CATCH(...) {
// This is suboptimal, but better than letting the exception leak
cont->vtable->cancel(cont.get(), std::current_exception());
}
}

@Amanieu
Copy link
Owner

Amanieu commented Jul 25, 2022

Nice catch, that should be a copy instead of a move.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants