summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/util.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-06-16 13:48:19 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-06-16 20:59:51 +0000
commit2bf942d8c21b653efdfdcae681769cffbfaa0663 (patch)
tree64c3e323c0ac00736db643f9a06976a52501761c /fpdfsdk/javascript/util.cpp
parent1e25e122849b0e16032f5b3d62bace4d3ce5253d (diff)
downloadpdfium-2bf942d8c21b653efdfdcae681769cffbfaa0663.tar.xz
Avoid a crash inside wcsftime() on Windows.chromium/3135chromium/3134chromium/3133
BUG=chromium:733245 Change-Id: Ic9347e2cc245831c0b71fac1d531c33c5646ab3f Reviewed-on: https://pdfium-review.googlesource.com/6671 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'fpdfsdk/javascript/util.cpp')
-rw-r--r--fpdfsdk/javascript/util.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/fpdfsdk/javascript/util.cpp b/fpdfsdk/javascript/util.cpp
index 72b94ab302..100a5caab4 100644
--- a/fpdfsdk/javascript/util.cpp
+++ b/fpdfsdk/javascript/util.cpp
@@ -250,6 +250,11 @@ bool util::printd(CJS_Runtime* pRuntime,
}
int iYear = jsDate.GetYear(pRuntime);
+ if (iYear < 0) {
+ sError = JSGetStringFromID(IDS_STRING_JSVALUEERROR);
+ return false;
+ }
+
int iMonth = jsDate.GetMonth(pRuntime);
int iDay = jsDate.GetDay(pRuntime);
int iHour = jsDate.GetHours(pRuntime);
@@ -290,7 +295,7 @@ bool util::printd(CJS_Runtime* pRuntime,
time.tm_sec = iSec;
wchar_t buf[64] = {};
- wcsftime(buf, 64, cFormat.c_str(), &time);
+ FXSYS_wcsftime(buf, 64, cFormat.c_str(), &time);
cFormat = buf;
vRet = CJS_Value(pRuntime, cFormat.c_str());
return true;