Skip to content

Commit 9500e58

Browse files
tniessenbengl
authored andcommitted
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. PR-URL: #42307 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent e17db8f commit 9500e58

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/node_url.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ unsigned hex2bin(const T ch) {
230230
return 10 + (ch - 'A');
231231
if (ch >= 'a' && ch <= 'f')
232232
return 10 + (ch - 'a');
233-
return static_cast<unsigned>(-1);
233+
UNREACHABLE();
234234
}
235235

236236
std::string PercentDecode(const char* input, size_t len) {

0 commit comments

Comments
 (0)