From 2bf942d8c21b653efdfdcae681769cffbfaa0663 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 16 Jun 2017 13:48:19 -0700 Subject: Avoid a crash inside wcsftime() on Windows. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BUG=chromium:733245 Change-Id: Ic9347e2cc245831c0b71fac1d531c33c5646ab3f Reviewed-on: https://pdfium-review.googlesource.com/6671 Commit-Queue: Lei Zhang Reviewed-by: Nicolás Peña --- fpdfsdk/javascript/util.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'fpdfsdk/javascript') 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; -- cgit v1.2.3