diff options
author | John Abd-El-Malek <jam@chromium.org> | 2014-06-23 15:24:28 -0700 |
---|---|---|
committer | John Abd-El-Malek <jam@chromium.org> | 2014-06-23 15:24:28 -0700 |
commit | 6c673585ed6bcb9e330ea5ab716f496c5d5f37b4 (patch) | |
tree | 0fd37d72e416fd2edb94373d18e08d6b8a33a303 /fpdfsdk/src/javascript | |
parent | 617089a3c1409be11fa130abb78dbd00b9e32d06 (diff) | |
download | pdfium-6c673585ed6bcb9e330ea5ab716f496c5d5f37b4.tar.xz |
Revert "Import Chromium base/numerics to resolve integer overflow."
This reverts commit d9713f05fdcecab8428d39034c6b84cd0bbd2920.
This is breaking compile.
Diffstat (limited to 'fpdfsdk/src/javascript')
-rw-r--r-- | fpdfsdk/src/javascript/Document.cpp | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp index 2318d9b834..0a6acfaea7 100644 --- a/fpdfsdk/src/javascript/Document.cpp +++ b/fpdfsdk/src/javascript/Document.cpp @@ -18,8 +18,6 @@ #include "../../include/javascript/Icon.h" #include "../../include/javascript/Field.h" -#include "../../../third_party/numerics/safe_math.h" - static v8::Isolate* GetIsolate(IFXJS_Context* cc) { CJS_Context* pContext = (CJS_Context *)cc; @@ -1427,17 +1425,16 @@ FX_BOOL Document::documentFileName(OBJ_PROP_PARAMS) CFX_WideString Document::ReversalStr(CFX_WideString cbFrom) { - size_t iLength = cbFrom.GetLength(); - base::CheckedNumeric<size_t> iSize = sizeof(wchar_t); - iSize *= (iLength + 1); - wchar_t* pResult = (wchar_t*)malloc(iSize.ValueOrDie()); - wchar_t* pFrom = (wchar_t*)cbFrom.GetBuffer(iLength); + wchar_t* pFrom = NULL; + int iLenth = cbFrom.GetLength(); + wchar_t* pResult = (wchar_t*)malloc((iLenth+1) * sizeof(wchar_t)); + memset(pResult, 0, (iLenth+1)); + pFrom = (wchar_t*)cbFrom.GetBuffer(iLenth); - for (size_t i = 0; i < iLength; i++) + for (int i = 0; i < iLenth; i++) { - pResult[i] = *(pFrom + iLength - i - 1); + pResult[i] = *(pFrom + iLenth - i - 1); } - pResult[iLength] = L'\0'; cbFrom.ReleaseBuffer(); CFX_WideString cbRet = CFX_WideString(pResult); @@ -1448,22 +1445,18 @@ CFX_WideString Document::ReversalStr(CFX_WideString cbFrom) CFX_WideString Document::CutString(CFX_WideString cbFrom) { - size_t iLength = cbFrom.GetLength(); - base::CheckedNumeric<size_t> iSize = sizeof(wchar_t); - iSize *= (iLength + 1); - wchar_t* pResult = (wchar_t*)malloc(iSize.ValueOrDie()); - wchar_t* pFrom = (wchar_t*)cbFrom.GetBuffer(iLength); + wchar_t* pFrom = NULL; + int iLenth = cbFrom.GetLength(); + wchar_t* pResult = (wchar_t*)malloc((iLenth+1) * sizeof(wchar_t)); + memset(pResult, 0, (iLenth+1)); + pFrom = (wchar_t*)cbFrom.GetBuffer(iLenth); - for (int i = 0; i < iLength; i++) + for (int i = 0; i < iLenth; i++) { if (pFrom[i] == L'\\' || pFrom[i] == L'/') - { - pResult[i] = L'\0'; break; - } pResult[i] = pFrom[i]; } - pResult[iLength] = L'\0'; cbFrom.ReleaseBuffer(); CFX_WideString cbRet = CFX_WideString(pResult); |