From 217b984839c2d11baf87d0997bc35fde260d31d1 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 2 Dec 2020 14:44:31 -0800 Subject: [PATCH] Fix crash in res.send() In commit c6fa25985b078ce0ba27da50d1d8676d3e18fe30, "var" usage was replaced with const. The code previously worked because "var" has function scoping unlike const which has block scoping. TypeError: Cannot read property 'attributes' of null --- lib/messages/search_response.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/messages/search_response.js b/lib/messages/search_response.js index bac7ab87..77edc7b1 100644 --- a/lib/messages/search_response.js +++ b/lib/messages/search_response.js @@ -42,7 +42,7 @@ SearchResponse.prototype.send = function (entry, nofiltering) { const self = this const savedAttrs = {} - const save = null + let save = null if (entry instanceof SearchEntry || entry instanceof SearchReference) { if (!entry.messageID) { entry.messageID = this.messageID } if (entry.messageID !== this.messageID) { throw new Error('SearchEntry messageID mismatch') } @@ -66,7 +66,7 @@ SearchResponse.prototype.send = function (entry, nofiltering) { } }) - const save = entry + save = entry entry = new SearchEntry({ objectName: typeof (save.dn) === 'string' ? parseDN(save.dn) : save.dn, messageID: self.messageID,