From 70d56be631ab6616cd7661468df6ba91c5821193 Mon Sep 17 00:00:00 2001 From: "sra@chromium.org" Date: Sat, 30 May 2009 00:47:49 +0000 Subject: Fix leaks found by Coverity Prevent. BUG=none TEST=none Review URL: http://codereview.chromium.org/115947 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17272 0039d316-1c4b-4281-b951-d872f2087c98 --- courgette/image_info_unittest.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'courgette/image_info_unittest.cc') diff --git a/courgette/image_info_unittest.cc b/courgette/image_info_unittest.cc index 6d6deb5..bf0ca6e 100644 --- a/courgette/image_info_unittest.cc +++ b/courgette/image_info_unittest.cc @@ -8,6 +8,7 @@ #include "base/path_service.h" #include "base/file_util.h" +#include "base/scoped_ptr.h" #include "base/string_util.h" #include "testing/gtest/include/gtest/gtest.h" @@ -27,15 +28,15 @@ class ImageInfoTest : public testing::Test { void TearDown() { } - void ExpectExecutable(courgette::PEInfo *info) const; + void ExpectExecutable(courgette::PEInfo* info) const; - std::string FileContents(const char *file_name) const; + std::string FileContents(const char* file_name) const; std::wstring test_dir_; }; // Reads a test file into a string. -std::string ImageInfoTest::FileContents(const char *file_name) const { +std::string ImageInfoTest::FileContents(const char* file_name) const { std::wstring file_path = test_dir_; file_util::AppendToPath(&file_path, UTF8ToWide(file_name)); std::string file_bytes; @@ -45,7 +46,7 @@ std::string ImageInfoTest::FileContents(const char *file_name) const { return file_bytes; } -void ImageInfoTest::ExpectExecutable(courgette::PEInfo *info) const { +void ImageInfoTest::ExpectExecutable(courgette::PEInfo* info) const { EXPECT_TRUE(info->ok()); EXPECT_TRUE(info->has_text_section()); } @@ -53,7 +54,7 @@ void ImageInfoTest::ExpectExecutable(courgette::PEInfo *info) const { void ImageInfoTest::TestExe() const { std::string file1 = FileContents("setup1.exe"); - courgette::PEInfo *info = new courgette::PEInfo(); + scoped_ptr info(new courgette::PEInfo()); info->Init(reinterpret_cast(file1.c_str()), file1.length()); bool can_parse_header = info->ParseHeader(); @@ -62,7 +63,7 @@ void ImageInfoTest::TestExe() const { // The executable is the whole file, not 'embedded' with the file EXPECT_EQ(file1.length(), info->length()); - ExpectExecutable(info); + ExpectExecutable(info.get()); EXPECT_EQ(449536, info->size_of_code()); EXPECT_EQ(SectionName(info->RVAToSection(0x00401234 - 0x00400000)), std::string(".text")); @@ -85,7 +86,7 @@ void ImageInfoTest::TestExe() const { void ImageInfoTest::TestResourceDll() const { std::string file1 = FileContents("en-US.dll"); - courgette::PEInfo *info = new courgette::PEInfo(); + scoped_ptr info(new courgette::PEInfo()); info->Init(reinterpret_cast(file1.c_str()), file1.length()); bool can_parse_header = info->ParseHeader(); -- cgit v1.1