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

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

Issue 1130763007: Fix potential UAF in ConcatInPlace. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Add comment before strange looking test. 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_wstring.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxcrt/fx_basic_wstring_unittest.cpp
diff --git a/core/src/fxcrt/fx_basic_wstring_unittest.cpp b/core/src/fxcrt/fx_basic_wstring_unittest.cpp
index 21b5ae54f64aa3453199f81ace4182bdf89afc86..847e5e8076cf7f646bd67bc4334c45965b818374 100644
--- a/core/src/fxcrt/fx_basic_wstring_unittest.cpp
+++ b/core/src/fxcrt/fx_basic_wstring_unittest.cpp
@@ -249,6 +249,33 @@ TEST(fxcrt, WideStringOperatorNE) {
EXPECT_TRUE(c_string3 != wide_string);
}
+TEST(fxcrt, WideStringConcatInPlace) {
+ CFX_WideString fred;
+ fred.ConcatInPlace(4, L"FRED");
+ EXPECT_EQ(L"FRED", fred);
+
+ fred.ConcatInPlace(2, L"DY");
+ EXPECT_EQ(L"FREDDY", fred);
+
+ fred.Delete(3, 3);
+ EXPECT_EQ(L"FRE", fred);
+
+ fred.ConcatInPlace(1, L"D");
+ EXPECT_EQ(L"FRED", fred);
+
+ CFX_WideString copy = fred;
+ fred.ConcatInPlace(2, L"DY");
+ EXPECT_EQ(L"FREDDY", fred);
+ EXPECT_EQ(L"FRED", copy);
+
+ // Test invalid arguments.
+ copy = fred;
+ fred.ConcatInPlace(-6, L"freddy");
+ CFX_WideString not_aliased(L"xxxxxx");
+ EXPECT_EQ(L"FREDDY", fred);
+ EXPECT_EQ(L"xxxxxx", not_aliased);
+}
+
#define ByteStringLiteral(str) CFX_ByteString(FX_BSTRC(str))
TEST(fxcrt, WideStringUTF16LE_Encode) {
« no previous file with comments | « core/src/fxcrt/fx_basic_wstring.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698