From 0899795beae2a8d52a893062ffc8c8a3ab72ac1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Sat, 12 Mar 2022 01:55:21 +0000 Subject: [PATCH] src: avoid returning invalid value from hex2bin If the input is not a valid hexadecimal digit, hex2bin should not return an invalid value, which is not handled correctly by the caller, which is the PercentDecode function. However, PercentDecode only ever calls the hex2bin function with valid hexadecimal digits, so mark the code path that previously returned an invalid value for non-digits as UNREACHABLE. --- src/node_url.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_url.cc b/src/node_url.cc index 79476e7a2f6a95..2541b95aa0c70d 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -230,7 +230,7 @@ unsigned hex2bin(const T ch) { return 10 + (ch - 'A'); if (ch >= 'a' && ch <= 'f') return 10 + (ch - 'a'); - return static_cast(-1); + UNREACHABLE(); } std::string PercentDecode(const char* input, size_t len) {