Skip to content

Commit e7a6ed9

Browse files
tniessenxtx1130
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: nodejs#42307 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 8e0cc4e commit e7a6ed9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎src/node_url.cc‎

Lines changed: 1 addition & 1 deletion
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)