diff --git a/libs/androidfw/tests/CursorWindow_test.cpp b/libs/androidfw/tests/CursorWindow_test.cpp index 15be80c481926..d1cfd03276c26 100644 --- a/libs/androidfw/tests/CursorWindow_test.cpp +++ b/libs/androidfw/tests/CursorWindow_test.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include "androidfw/CursorWindow.h" @@ -184,7 +185,7 @@ TEST(CursorWindowTest, Inflate) { ASSERT_EQ(w->allocRow(), OK); // Scratch buffer that will fit before inflation - void* buf = malloc(kHalfInlineSize); + char buf[kHalfInlineSize]; // Store simple value ASSERT_EQ(w->putLong(0, 0, 0xcafe), OK); @@ -262,7 +263,7 @@ TEST(CursorWindowTest, ParcelSmall) { ASSERT_EQ(w->allocRow(), OK); // Scratch buffer that will fit before inflation - void* buf = malloc(kHalfInlineSize); + char buf[kHalfInlineSize]; // Store simple value ASSERT_EQ(w->putLong(0, 0, 0xcafe), OK); @@ -322,7 +323,8 @@ TEST(CursorWindowTest, ParcelLarge) { ASSERT_EQ(w->putLong(0, 0, 0xcafe), OK); // Store object that forces inflation - void* buf = malloc(kGiantSize); + std::unique_ptr bufPtr(new char[kGiantSize]); + void* buf = bufPtr.get(); memset(buf, 42, kGiantSize); ASSERT_EQ(w->putBlob(0, 1, buf, kGiantSize), OK);