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

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

Issue 1136673005: Merge to XFA: Add safe FX_Alloc2D() macro (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_array.cpp ('k') | core/src/fxge/agg/agg23/fx_agg_path_storage.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxcrt/fx_basic_memmgr_unittest.cpp
diff --git a/core/src/fxcrt/fx_basic_memmgr_unittest.cpp b/core/src/fxcrt/fx_basic_memmgr_unittest.cpp
index 565021d29e08880eb283b4e689abe92eba844fb7..c70f3b197d53777ee50fa23ac9601a4851d653bd 100644
--- a/core/src/fxcrt/fx_basic_memmgr_unittest.cpp
+++ b/core/src/fxcrt/fx_basic_memmgr_unittest.cpp
@@ -12,6 +12,8 @@ namespace {
const size_t kMaxByteAlloc = std::numeric_limits<size_t>::max();
const size_t kMaxIntAlloc = kMaxByteAlloc / sizeof(int);
const size_t kOverflowIntAlloc = kMaxIntAlloc + 100;
+const size_t kWidth = 640;
+const size_t kOverflowIntAlloc2D = kMaxIntAlloc / kWidth + 10;
} // namespace
@@ -35,6 +37,11 @@ TEST(fxcrt, FX_AllocOverflow) {
FX_Free(ptr);
}
+TEST(fxcrt, FX_AllocOverflow2D) {
+ EXPECT_DEATH_IF_SUPPORTED(
+ FX_Alloc2D(int, kWidth, kOverflowIntAlloc2D), "");
+}
+
TEST(fxcrt, DISABLED_FX_TryAllocOOM) {
EXPECT_FALSE(FX_TryAlloc(int, kMaxIntAlloc));
« no previous file with comments | « core/src/fxcrt/fx_basic_array.cpp ('k') | core/src/fxge/agg/agg23/fx_agg_path_storage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698