From af5d98641dbe7af65cc14d27cef1b0bde751fee9 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sun, 23 Sep 2018 23:44:10 -0400 Subject: [PATCH] http2: close fd in doSendFileFD() This commit closes the file descriptor in two code paths that return from doSendFileFD(). PR-URL: https://github.com/nodejs/node/pull/23047 Fixes: https://github.com/nodejs/node/issues/23029 Reviewed-By: Ruben Bridgewater Reviewed-By: Matteo Collina Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat --- lib/internal/http2/core.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index d5ea26374fcaec..487bbe4f3b8a0f 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -2149,6 +2149,7 @@ function doSendFileFD(session, options, fd, headers, streamOptions, err, stat) { isDirectory) { const err = isDirectory ? new ERR_HTTP2_SEND_FILE() : new ERR_HTTP2_SEND_FILE_NOSEEK(); + tryClose(fd); if (onError) onError(err); else @@ -2179,6 +2180,7 @@ function doSendFileFD(session, options, fd, headers, streamOptions, err, stat) { if ((typeof options.statCheck === 'function' && options.statCheck.call(this, stat, headers) === false) || (this[kState].flags & STREAM_FLAGS_HEADERS_SENT)) { + tryClose(fd); return; }