summaryrefslogtreecommitdiffstats
path: root/libqpdf/JSON.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <jberkenbilt@users.noreply.github.com>2023-04-01 15:31:28 +0200
committerGitHub <noreply@github.com>2023-04-01 15:31:28 +0200
commitef6f5a97f42a6d59abc9ca81ae4e9ab3b7168f55 (patch)
tree49a9071c15e3947d581cb33f2d5bfc129e1c9593 /libqpdf/JSON.cc
parentb62ad7ecc625963da9578d47d1ccb2809d6f0452 (diff)
parent5f4f553c3588f3ef3cb704c9d3c6db6bb78ccfa9 (diff)
downloadqpdf-ef6f5a97f42a6d59abc9ca81ae4e9ab3b7168f55.tar.zst
Merge pull request #936 from m-holger/hex
Refactor QUtil::hex_decode
Diffstat (limited to 'libqpdf/JSON.cc')
-rw-r--r--libqpdf/JSON.cc8
1 files changed, 2 insertions, 6 deletions
diff --git a/libqpdf/JSON.cc b/libqpdf/JSON.cc
index cb60eabc..fbf06f88 100644
--- a/libqpdf/JSON.cc
+++ b/libqpdf/JSON.cc
@@ -1121,12 +1121,8 @@ JSONParser::getToken()
case ls_u4:
using ui = unsigned int;
- if ('0' <= *p && *p <= '9') {
- u_value = 16 * u_value + (ui(*p) - ui('0'));
- } else if ('a' <= *p && *p <= 'f') {
- u_value = 16 * u_value + (10 + ui(*p) - ui('a'));
- } else if ('A' <= *p && *p <= 'F') {
- u_value = 16 * u_value + (10 + ui(*p) - ui('A'));
+ if (ui val = ui(QUtil::hex_decode_char(*p)); val < 16) {
+ u_value = 16 * u_value + val;
} else {
tokenError();
}