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

Unified Diff: core/src/fxcrt/fx_basic_bstring_unittest.cpp

Issue 1123333004: Merge to XFA: Fix potential UAF in ConcatInPlace. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 7 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 | « core/src/fxcrt/fx_basic_bstring.cpp ('k') | core/src/fxcrt/fx_basic_wstring.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxcrt/fx_basic_bstring_unittest.cpp
diff --git a/core/src/fxcrt/fx_basic_bstring_unittest.cpp b/core/src/fxcrt/fx_basic_bstring_unittest.cpp
index 1f80207e96604faf46c4fafd3489f85565be9df0..bcdd33b8b8e67f0d070336c2f7f99b043d2cabf7 100644
--- a/core/src/fxcrt/fx_basic_bstring_unittest.cpp
+++ b/core/src/fxcrt/fx_basic_bstring_unittest.cpp
@@ -288,6 +288,33 @@ TEST(fxcrt, ByteStringCNull) {
EXPECT_NE(null_string, non_null_string);
}
+TEST(fxcrt, ByteStringConcatInPlace) {
+ CFX_ByteString fred;
+ fred.ConcatInPlace(4, "FRED");
+ EXPECT_EQ("FRED", fred);
+
+ fred.ConcatInPlace(2, "DY");
+ EXPECT_EQ("FREDDY", fred);
+
+ fred.Delete(3, 3);
+ EXPECT_EQ("FRE", fred);
+
+ fred.ConcatInPlace(1, "D");
+ EXPECT_EQ("FRED", fred);
+
+ CFX_ByteString copy = fred;
+ fred.ConcatInPlace(2, "DY");
+ EXPECT_EQ("FREDDY", fred);
+ EXPECT_EQ("FRED", copy);
+
+ // Test invalid arguments.
+ copy = fred;
+ fred.ConcatInPlace(-6, "freddy");
+ CFX_ByteString not_aliased("xxxxxx");
+ EXPECT_EQ("FREDDY", fred);
+ EXPECT_EQ("xxxxxx", not_aliased);
+}
+
TEST(fxcrt, ByteStringCNotNull) {
CFX_ByteStringC string3("abc");
CFX_ByteStringC string6("abcdef");
« no previous file with comments | « core/src/fxcrt/fx_basic_bstring.cpp ('k') | core/src/fxcrt/fx_basic_wstring.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698