diff options
author | Ryan Harrison <rharrison@chromium.org> | 2017-10-25 14:32:14 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-10-25 18:50:23 +0000 |
commit | 1e19e25cd10c24f25beddff56b7c4b5fdc5adbcb (patch) | |
tree | 0dbc342a37e7d28dbf76a0dc9a10d77fabe5f289 /xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp | |
parent | 8f524d6ff9c5c5e07388438e58aca7dc39f43a1f (diff) | |
download | pdfium-1e19e25cd10c24f25beddff56b7c4b5fdc5adbcb.tar.xz |
Add in depth check for ToJavascript and related methods
There exists a similar check for the parser, but it doesn't catch all
cases of excessive memory usage, since a single parse step can
generate multiple expressions that need to be converted or other cases
where the parse depth doesn't match the emission depth later.
Due to the expressions appearing in two different inheritence
hierachies the depth information needs to be stored outside of the
classes, thus the new depth class.
Another way to handle this would be to change the method calls to take
in a visitor object that tracks depth. This would require significant
reworking of some of the code, so I am going to file a bug about doing
that conversion as a cleanup.
BUG=chromium:752495
Change-Id: Ica7c9b60ecf1e17530ea88b7bfb01582c63043be
Reviewed-on: https://pdfium-review.googlesource.com/16752
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp')
-rw-r--r-- | xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp b/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp index 192f935309..8582649fec 100644 --- a/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp +++ b/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp @@ -10,6 +10,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/test_support.h" #include "third_party/base/ptr_util.h" +#include "xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.h" TEST(CXFA_FMParserTest, Empty) { auto parser = pdfium::MakeUnique<CXFA_FMParser>(L""); @@ -17,6 +18,7 @@ TEST(CXFA_FMParserTest, Empty) { ASSERT(ast != nullptr); EXPECT_FALSE(parser->HasError()); + CXFA_FMToJavaScriptDepth::Reset(); CFX_WideTextBuf buf; EXPECT_TRUE(ast->ToJavaScript(buf)); // TODO(dsinclair): This is a little weird ..... @@ -31,6 +33,7 @@ TEST(CXFA_FMParserTest, CommentOnlyIsError) { EXPECT_FALSE(parser->HasError()); // EXPECT_TRUE(parser->HasError()); + CXFA_FMToJavaScriptDepth::Reset(); CFX_WideTextBuf buf; EXPECT_TRUE(ast->ToJavaScript(buf)); EXPECT_EQ(L"// comments only", buf.AsStringView()); @@ -49,6 +52,7 @@ TEST(CXFA_FMParserTest, CommentThenValue) { ASSERT(ast != nullptr); EXPECT_FALSE(parser->HasError()); + CXFA_FMToJavaScriptDepth::Reset(); CFX_WideTextBuf buf; EXPECT_TRUE(ast->ToJavaScript(buf)); EXPECT_EQ(ret, buf.AsStringView()); @@ -104,6 +108,7 @@ TEST(CXFA_FMParserTest, Parse) { ASSERT(ast != nullptr); EXPECT_FALSE(parser->HasError()); + CXFA_FMToJavaScriptDepth::Reset(); CFX_WideTextBuf buf; EXPECT_TRUE(ast->ToJavaScript(buf)); EXPECT_EQ(ret, buf.AsStringView()); |