summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp2
-rw-r--r--fpdfsdk/src/javascript/Document.cpp6
-rw-r--r--testing/resources/javascript/document_methods.in1
-rw-r--r--testing/resources/javascript/document_methods_expected.txt1
4 files changed, 8 insertions, 2 deletions
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
index 9e1434139c..63454d2cb5 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
@@ -410,7 +410,7 @@ CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj) {
CFX_ByteString key;
CPDF_Object* pValue = p->GetNextElement(pos, key);
buf << FX_BSTRC("/") << PDF_NameEncode(key);
- if (pValue->GetObjNum()) {
+ if (pValue && pValue->GetObjNum()) {
buf << " " << pValue->GetObjNum() << FX_BSTRC(" 0 R ");
} else {
buf << pValue;
diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp
index a8797095d8..91805b825e 100644
--- a/fpdfsdk/src/javascript/Document.cpp
+++ b/fpdfsdk/src/javascript/Document.cpp
@@ -1367,8 +1367,12 @@ FX_BOOL Document::addIcon(IFXJS_Context* cc,
sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
return FALSE;
}
-
CFX_WideString swIconName = params[0].ToCFXWideString();
+
+ if (params[1].GetType() != VT_object) {
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR);
+ return FALSE;
+ }
JSFXObject pJSIcon = params[1].ToV8Object();
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
diff --git a/testing/resources/javascript/document_methods.in b/testing/resources/javascript/document_methods.in
index b2467f37c4..3cd3330b87 100644
--- a/testing/resources/javascript/document_methods.in
+++ b/testing/resources/javascript/document_methods.in
@@ -122,6 +122,7 @@ function testAddIcon() {
// Second argument must actually be an icon.
expectError('this.addIcon("myicon", 3)');
+ expectError('this.addIcon("myicon", undefined)');
// TODO(tsepez): test success cases.
}
diff --git a/testing/resources/javascript/document_methods_expected.txt b/testing/resources/javascript/document_methods_expected.txt
index 753a99df6e..26f7b542dd 100644
--- a/testing/resources/javascript/document_methods_expected.txt
+++ b/testing/resources/javascript/document_methods_expected.txt
@@ -77,6 +77,7 @@ Alert: PASS: this.addIcon() threw error Document.addIcon: Incorrect number of pa
Alert: PASS: this.addIcon(1) threw error Document.addIcon: Incorrect number of parameters passed to function.
Alert: PASS: this.addIcon(1, 2, 3) threw error Document.addIcon: Incorrect number of parameters passed to function.
Alert: PASS: this.addIcon("myicon", 3) threw error Document.addIcon: Incorrect parameter type.
+Alert: PASS: this.addIcon("myicon", undefined) threw error Document.addIcon: Incorrect parameter type.
Alert: PASS: typeof this.calculateNow = function
Alert: PASS: typeof this.getField = function
Alert: PASS: this.getField() threw error Document.getField: Incorrect number of parameters passed to function.