summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorOliver Chang <ochang@chromium.org>2016-03-03 09:28:57 -0800
committerOliver Chang <ochang@chromium.org>2016-03-03 09:28:57 -0800
commitda17d6cd9a4abc6ff41e18faa2757f98caf797db (patch)
treec97d0bdb540e91d917586d760c53cab13608802c /xfa
parent457f421dab11104402be34a55613ffe20d44bdda (diff)
downloadpdfium-da17d6cd9a4abc6ff41e18faa2757f98caf797db.tar.xz
Don't allow empty expression in CXFA_FMParse::ParseParenExpression.
BUG=pdfium:404 R=jun_fang@foxitsoftware.com, tsepez@chromium.org Review URL: https://codereview.chromium.org/1742903002 .
Diffstat (limited to 'xfa')
-rw-r--r--xfa/src/fxfa/src/fm2js/xfa_error.cpp1
-rw-r--r--xfa/src/fxfa/src/fm2js/xfa_error.h1
-rw-r--r--xfa/src/fxfa/src/fm2js/xfa_fmparse.cpp36
3 files changed, 21 insertions, 17 deletions
diff --git a/xfa/src/fxfa/src/fm2js/xfa_error.cpp b/xfa/src/fxfa/src/fm2js/xfa_error.cpp
index fdeee363bb..03423b0673 100644
--- a/xfa/src/fxfa/src/fm2js/xfa_error.cpp
+++ b/xfa/src/fxfa/src/fm2js/xfa_error.cpp
@@ -11,6 +11,7 @@ static const FX_WCHAR* const gs_lpStrErrorMsgInfo[] = {
L"invalidate char '%c'", L"expected identifier instead of '%s'",
L"expected '%s' instead of '%s'", L"expected 'endif' instead of '%s'",
L"unexpected expression '%s'", L"expected operator '%s' instead of '%s'",
+ L"expected non-empty expression",
};
const FX_WCHAR* XFA_FM_ErrorMsg(XFA_FM_ERRMSG msg) {
diff --git a/xfa/src/fxfa/src/fm2js/xfa_error.h b/xfa/src/fxfa/src/fm2js/xfa_error.h
index 474b28b7c9..8907ad872f 100644
--- a/xfa/src/fxfa/src/fm2js/xfa_error.h
+++ b/xfa/src/fxfa/src/fm2js/xfa_error.h
@@ -19,6 +19,7 @@ enum XFA_FM_ERRMSG {
FMERR_EXPECTED_IFEND,
FMERR_UNEXPECTED_EXPRESSION,
FMERR_EXPTECTED_OPERATOR,
+ FMERR_EXPECTED_NON_EMPTY_EXPRESSION,
FMERR_MAXIMUM
};
diff --git a/xfa/src/fxfa/src/fm2js/xfa_fmparse.cpp b/xfa/src/fxfa/src/fm2js/xfa_fmparse.cpp
index 6841cdaca5..bd2c206f03 100644
--- a/xfa/src/fxfa/src/fm2js/xfa_fmparse.cpp
+++ b/xfa/src/fxfa/src/fm2js/xfa_fmparse.cpp
@@ -782,26 +782,28 @@ CXFA_FMSimpleExpression* CXFA_FMParse::ParseIndexExpression() {
}
CXFA_FMSimpleExpression* CXFA_FMParse::ParseParenExpression() {
- FX_DWORD line = m_pToken->m_uLinenum;
Check(TOKlparen);
- std::unique_ptr<CXFA_FMSimpleExpression> pExp1;
- if (m_pToken->m_type != TOKrparen) {
- pExp1.reset(ParseLogicalOrExpression());
- while (m_pToken->m_type == TOKassign) {
- NextToken();
- std::unique_ptr<CXFA_FMSimpleExpression> pExp2(
- ParseLogicalOrExpression());
- if (m_pErrorInfo->message.IsEmpty()) {
- pExp1.reset(new CXFA_FMAssignExpression(
- line, TOKassign, pExp1.release(), pExp2.release()));
- } else {
- pExp1.reset();
- }
- }
- Check(TOKrparen);
- } else {
+
+ if (m_pToken->m_type == TOKrparen) {
+ Error(m_pToken->m_uLinenum, FMERR_EXPECTED_NON_EMPTY_EXPRESSION);
NextToken();
+ return nullptr;
}
+
+ FX_DWORD line = m_pToken->m_uLinenum;
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp1(ParseLogicalOrExpression());
+
+ while (m_pToken->m_type == TOKassign) {
+ NextToken();
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp2(ParseLogicalOrExpression());
+ if (m_pErrorInfo->message.IsEmpty()) {
+ pExp1.reset(new CXFA_FMAssignExpression(line, TOKassign, pExp1.release(),
+ pExp2.release()));
+ } else {
+ pExp1.reset();
+ }
+ }
+ Check(TOKrparen);
return pExp1.release();
}