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

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

Issue 423953002: Tidy up app::response(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: 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 | « no previous file | no next file » | 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 3b92a992d9d0be2b46db2266d0e51847b0a34fdd..0500655055e6e4c3c1ea1a3119ad8214ab9acd88 100644
--- a/fpdfsdk/src/javascript/app.cpp
+++ b/fpdfsdk/src/javascript/app.cpp
@@ -1037,15 +1037,13 @@ FX_BOOL app::response(OBJ_METHOD_PARAMS)
CFX_WideString swTitle = L"PDF";
#endif
CFX_WideString swDefault = L"";
- CFX_WideString swResponse = L"";
bool bPassWord = false;
-
+
v8::Isolate* isolate = GetIsolate(cc);
-
- int iLength = params.size();
+
+ int iLength = params.size();
if (iLength > 0 && params[0].GetType() == VT_object)
{
-
JSObject pObj = (JSObject )params[0];
v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj,L"cQuestion");
swQuestion = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).operator CFX_WideString();
@@ -1104,19 +1102,15 @@ FX_BOOL app::response(OBJ_METHOD_PARAMS)
int nLength = 2048;
char* pBuff = new char[nLength];
jun_fang 2014/07/29 04:11:30 nLength is the length of content. Doesn't include
Tom Sepez 2014/07/29 16:55:57 Yeah, I'm having a hard time reconciling this with
jun_fang 2014/07/29 17:31:47 In theory, there is no difference between 2046 plu
nLength = pApp->JS_appResponse(swQuestion, swTitle, swDefault, swLabel, bPassWord, pBuff, nLength);
- if(nLength<=0)
+ if (nLength <= 0 || nLength > sizeof(pBuff))
jun_fang 2014/07/29 04:11:30 Sizeof(pBuff) is 4 which represents bytes of a poi
Tom Sepez 2014/07/29 16:55:57 Good catch. Looks like this has been wrong for ye
jun_fang 2014/07/29 17:31:47 Strlen depends upon the last char '\0'. That's why
{
- delete[] pBuff;
vRet.SetNull();
+ delete[] pBuff;
return FALSE;
}
- else
- {
- nLength = nLength > sizeof(pBuff) ? sizeof(pBuff) : nLength;
- vRet = swResponse = CFX_WideString::FromUTF16LE((unsigned short*)pBuff, nLength / 2);
- }
- delete[] pBuff;
+ vRet = CFX_WideString::FromUTF16LE((unsigned short*)pBuff, nLength / 2);
+ delete[] pBuff;
return TRUE;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698