summaryrefslogtreecommitdiff
path: root/fxjs/cfxjse_formcalc_context.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-08-07 17:02:12 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-07 17:02:12 +0000
commitc0352f4584bf738b0073114d25e81e57b490d655 (patch)
tree5c3f5a9e619f318dd5e4e34069d487b868d8992c /fxjs/cfxjse_formcalc_context.cpp
parentf3a3393a2f96bb8c4cc275ee67921e2b7bddf540 (diff)
downloadpdfium-c0352f4584bf738b0073114d25e81e57b490d655.tar.xz
Speculative fix for null deref above ThrowNoDefaultPropertyException
Avoid possibility of an unterminated string or nullptr by avoiding stringviews, since the non-view classes copy and always provide a suitable result. Always use %ls and widestrings in wprintf() variants, since that combination is consistent across our platforms (%s, %S, etc. have idiosyncracies). Bug: 870952 Change-Id: Ief62a42c3486e8298f9583b56e9333db1a74972a Reviewed-on: https://pdfium-review.googlesource.com/39551 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fxjs/cfxjse_formcalc_context.cpp')
-rw-r--r--fxjs/cfxjse_formcalc_context.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/fxjs/cfxjse_formcalc_context.cpp b/fxjs/cfxjse_formcalc_context.cpp
index cf42fb26c7..4201059c06 100644
--- a/fxjs/cfxjse_formcalc_context.cpp
+++ b/fxjs/cfxjse_formcalc_context.cpp
@@ -6199,9 +6199,8 @@ void CFXJSE_FormCalcContext::GlobalPropertyGetter(CFXJSE_Value* pValue) {
void CFXJSE_FormCalcContext::ThrowNoDefaultPropertyException(
const ByteStringView& name) const {
- // TODO(tsepez): check usage of c_str() below.
- ThrowException(L"%.16S doesn't have a default property.",
- name.unterminated_c_str());
+ ThrowException(L"%ls doesn't have a default property.",
+ WideString::FromUTF8(name).c_str());
}
void CFXJSE_FormCalcContext::ThrowCompilerErrorException() const {
@@ -6220,14 +6219,14 @@ void CFXJSE_FormCalcContext::ThrowPropertyNotInObjectException(
const WideString& name,
const WideString& exp) const {
ThrowException(
- L"An attempt was made to reference property '%.16s' of a non-object "
- L"in SOM expression %.16s.",
+ L"An attempt was made to reference property '%ls' of a non-object "
+ L"in SOM expression %ls.",
name.c_str(), exp.c_str());
}
void CFXJSE_FormCalcContext::ThrowParamCountMismatchException(
const WideString& method) const {
- ThrowException(L"Incorrect number of parameters calling method '%.16s'.",
+ ThrowException(L"Incorrect number of parameters calling method '%ls'.",
method.c_str());
}