unix,win: ensure req->bufs is freed
This commit ensures that req->bufs (req->fs.info.bufs on Windows) is initialized to NULL in INIT and freed, if necessary, in uv_fs_req_cleanup(). Refs: https://github.com/libuv/libuv/pull/1751#discussion_r169645330 PR-URL: https://github.com/libuv/libuv/pull/1752 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
parent
e485d28674
commit
1167ec3f47
@ -75,6 +75,7 @@
|
||||
req->loop = loop; \
|
||||
req->path = NULL; \
|
||||
req->new_path = NULL; \
|
||||
req->bufs = NULL; \
|
||||
req->cb = cb; \
|
||||
} \
|
||||
while (0)
|
||||
@ -1485,6 +1486,10 @@ void uv_fs_req_cleanup(uv_fs_t* req) {
|
||||
if (req->fs_type == UV_FS_SCANDIR && req->ptr != NULL)
|
||||
uv__fs_scandir_cleanup(req);
|
||||
|
||||
if (req->bufs != req->bufsml)
|
||||
uv__free(req->bufs);
|
||||
req->bufs = NULL;
|
||||
|
||||
if (req->ptr != &req->statbuf)
|
||||
uv__free(req->ptr);
|
||||
req->ptr = NULL;
|
||||
|
||||
@ -245,6 +245,7 @@ INLINE static void uv_fs_req_init(uv_loop_t* loop, uv_fs_t* req,
|
||||
req->ptr = NULL;
|
||||
req->path = NULL;
|
||||
req->cb = cb;
|
||||
req->fs.info.bufs = NULL;
|
||||
memset(&req->fs, 0, sizeof(req->fs));
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user