From 02dcde08386441d5a89dbcb602a1ad367a506cc0 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 9 Feb 2017 11:41:36 -0800 Subject: [PATCH] win,fs: avoid double freeing uv_fs_event_t.dirw Set `dirw` to `pathw` after `uv_fs_event_start` is known to be completed successfully. Fixes: https://github.com/libuv/libuv/issues/1221 PR-URL: https://github.com/libuv/libuv/pull/1222 Reviewed-By: Ben Noordhuis Reviewed-By: Santiago Gimeno --- src/win/fs-event.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/win/fs-event.c b/src/win/fs-event.c index 03e4adc0..05fc1d01 100644 --- a/src/win/fs-event.c +++ b/src/win/fs-event.c @@ -188,7 +188,6 @@ int uv_fs_event_start(uv_fs_event_t* handle, if (is_path_dir) { /* path is a directory, so that's the directory that we will watch. */ - handle->dirw = pathw; dir_to_watch = pathw; } else { /* @@ -274,6 +273,8 @@ int uv_fs_event_start(uv_fs_event_t* handle, goto error; } + assert(is_path_dir ? pathw != NULL : pathw == NULL); + handle->dirw = pathw; handle->req_pending = 1; return 0;