From a66070b1844fce59b9dabb5e765b9ef21a2704c8 Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Wed, 20 May 2020 13:25:50 -0700 Subject: [PATCH] Fix BufferAndPlanClearingTest Properly instantiate this parameterized test target. PiperOrigin-RevId: 312543593 Change-Id: I4a104c8f0ffff30e79bdc0b0f9c89ae30ca4c34e --- tensorflow/lite/simple_memory_arena.cc | 2 ++ tensorflow/lite/simple_memory_arena_test.cc | 3 +++ 2 files changed, 5 insertions(+) diff --git a/tensorflow/lite/simple_memory_arena.cc b/tensorflow/lite/simple_memory_arena.cc index a4d6d19656b..4aa0a1eb2ef 100644 --- a/tensorflow/lite/simple_memory_arena.cc +++ b/tensorflow/lite/simple_memory_arena.cc @@ -136,6 +136,8 @@ TfLiteStatus SimpleMemoryArena::ResolveAlloc( char** output_ptr) { TF_LITE_ENSURE(context, committed_); TF_LITE_ENSURE(context, output_ptr != nullptr); + TF_LITE_ENSURE(context, + underlying_buffer_size_ >= (alloc.offset + alloc.size)); if (alloc.size == 0) { *output_ptr = nullptr; } else { diff --git a/tensorflow/lite/simple_memory_arena_test.cc b/tensorflow/lite/simple_memory_arena_test.cc index fe337562b0a..0196421cc9c 100644 --- a/tensorflow/lite/simple_memory_arena_test.cc +++ b/tensorflow/lite/simple_memory_arena_test.cc @@ -197,6 +197,9 @@ TEST_P(BufferAndPlanClearingTest, TestClearBufferAndClearPlan) { EXPECT_NE(resolved_ptr, nullptr); } +INSTANTIATE_TEST_SUITE_P(BufferAndPlanClearingTest, BufferAndPlanClearingTest, + ::testing::Values(true, false)); + } // namespace } // namespace tflite