Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
unix: make it safe to delete the default loop
Browse files Browse the repository at this point in the history
Fixes a potential free() of non-malloc'ed memory.
  • Loading branch information
bnoordhuis committed Dec 4, 2011
1 parent 248ca5d commit 34e95d1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/unix/core.c
Expand Up @@ -169,7 +169,15 @@ uv_loop_t* uv_loop_new(void) {
void uv_loop_delete(uv_loop_t* loop) {
uv_ares_destroy(loop, loop->channel);
ev_loop_destroy(loop->ev);
free(loop);

#ifndef NDEBUG
memset(loop, 0, sizeof *loop);
#endif

if (loop == default_loop_ptr)
default_loop_ptr = NULL;
else
free(loop);
}


Expand Down

0 comments on commit 34e95d1

Please sign in to comment.