summaryrefslogtreecommitdiff
path: root/core/fxcrt
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2017-04-18 13:12:41 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-04-18 18:38:11 +0000
commitecd36468b5639873295859f29b185c517476cb45 (patch)
treed952edf134127126e4ae1f683d0a474e467c7118 /core/fxcrt
parent994acdc1a31015674e786d24cc37d08dfae6d863 (diff)
downloadpdfium-ecd36468b5639873295859f29b185c517476cb45.tar.xz
Check char sign in fx_ext.h
The std methods assume that the input can be represented as unsigned char. Bug: pdfium:703 Change-Id: I11d20869502aff0ebb8badca853398a7d0232338 Reviewed-on: https://pdfium-review.googlesource.com/4171 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxcrt')
-rw-r--r--core/fxcrt/fx_ext.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/core/fxcrt/fx_ext.h b/core/fxcrt/fx_ext.h
index d7f21af9ff..8224087d88 100644
--- a/core/fxcrt/fx_ext.h
+++ b/core/fxcrt/fx_ext.h
@@ -57,15 +57,19 @@ inline bool FXSYS_iswspace(wchar_t c) {
return (c == 0x20) || (c == 0x0d) || (c == 0x0a) || (c == 0x09);
}
+inline bool FXSYS_isHexDigit(const char c) {
+ return !((c & 0x80) || !std::isxdigit(c));
+}
+
inline int FXSYS_toHexDigit(const char c) {
- if (!std::isxdigit(c))
+ if (!FXSYS_isHexDigit(c))
return 0;
char upchar = std::toupper(c);
return upchar > '9' ? upchar - 'A' + 10 : upchar - '0';
}
inline bool FXSYS_isDecimalDigit(const char c) {
- return !!std::isdigit(c);
+ return !((c & 0x80) || !std::isdigit(c));
}
inline bool FXSYS_isDecimalDigit(const wchar_t c) {
@@ -73,7 +77,7 @@ inline bool FXSYS_isDecimalDigit(const wchar_t c) {
}
inline int FXSYS_toDecimalDigit(const char c) {
- return std::isdigit(c) ? c - '0' : 0;
+ return FXSYS_isDecimalDigit(c) ? c - '0' : 0;
}
inline int FXSYS_toDecimalDigit(const wchar_t c) {