Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: fpdfsdk/src/javascript/app.cpp

Issue 383563002: Fix an out-of-boundary issue for wide string (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Add WStringLength function Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fpdfsdk/src/javascript/Document.cpp ('k') | fpdfsdk/src/jsapi/fxjs_v8.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/src/javascript/app.cpp
diff --git a/fpdfsdk/src/javascript/app.cpp b/fpdfsdk/src/javascript/app.cpp
index a3e61c01abe6e22c593d8ab45b780d38779cdcc1..3b92a992d9d0be2b46db2266d0e51847b0a34fdd 100644
--- a/fpdfsdk/src/javascript/app.cpp
+++ b/fpdfsdk/src/javascript/app.cpp
@@ -886,15 +886,15 @@ FX_BOOL app::browseForDoc(OBJ_METHOD_PARAMS)
{
JSObject pObj = (JSObject )params[0];
- v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj,L"bSave");
- bSave = (bool)CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue));
-
+ v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj,L"bSave");
+ bSave = (bool)CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue));
+
pValue = JS_GetObjectElement(isolate, pObj,L"cFilenameInit");
{
CJS_Value t = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue));
- cFilenameInit = t.operator CFX_ByteString();
+ cFilenameInit = t.operator CFX_ByteString();
}
-
+
pValue = JS_GetObjectElement(isolate,pObj,L"cFSInit");
{
CJS_Value t = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue));
@@ -1097,25 +1097,23 @@ FX_BOOL app::response(OBJ_METHOD_PARAMS)
}
CJS_Context* pContext = (CJS_Context *)cc;
- ASSERT(pContext != NULL);
+ ASSERT(pContext != NULL);
CPDFDoc_Environment* pApp = pContext->GetReaderApp();
- ASSERT(pApp != NULL);
+ ASSERT(pApp != NULL);
int nLength = 2048;
char* pBuff = new char[nLength];
nLength = pApp->JS_appResponse(swQuestion, swTitle, swDefault, swLabel, bPassWord, pBuff, nLength);
if(nLength<=0)
{
+ delete[] pBuff;
vRet.SetNull();
return FALSE;
}
else
{
- nLength = nLength>2046?2046:nLength;
- pBuff[nLength] = 0;
- pBuff[nLength+1] = 0;
- swResponse = CFX_WideString::FromUTF16LE((unsigned short*)pBuff, nLength);
- vRet = swResponse;
+ nLength = nLength > sizeof(pBuff) ? sizeof(pBuff) : nLength;
+ vRet = swResponse = CFX_WideString::FromUTF16LE((unsigned short*)pBuff, nLength / 2);
}
delete[] pBuff;
« no previous file with comments | « fpdfsdk/src/javascript/Document.cpp ('k') | fpdfsdk/src/jsapi/fxjs_v8.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698