Skip to content

Commit

Permalink
Merge "Fix the dangling pointer when setting up arguments of imgdiff"
Browse files Browse the repository at this point in the history
  • Loading branch information
Tianjie Xu authored and Gerrit Code Review committed Sep 17, 2017
2 parents 6e7df82 + 8ba7c45 commit ca5a071
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions tests/component/imgdiff_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,9 +779,10 @@ TEST(ImgdiffTest, zip_mode_store_large_apk) {
// Compute patch.
TemporaryFile patch_file;
TemporaryDir debug_dir;
std::string debug_dir_arg = android::base::StringPrintf("--debug-dir=%s", debug_dir.path);
std::vector<const char*> args = {
"imgdiff", "-z", "--block-limit=10", android::base::StringPrintf(
"--debug-dir=%s", debug_dir.path).c_str(), src_file.path, tgt_file.path, patch_file.path,
"imgdiff", "-z", "--block-limit=10", debug_dir_arg.c_str(), src_file.path, tgt_file.path,
patch_file.path,
};
ASSERT_EQ(0, imgdiff(args.size(), args.data()));

Expand Down Expand Up @@ -901,9 +902,10 @@ TEST(ImgdiffTest, zip_mode_no_match_source) {
// Compute patch.
TemporaryFile patch_file;
TemporaryDir debug_dir;
std::string debug_dir_arg = android::base::StringPrintf("--debug-dir=%s", debug_dir.path);
std::vector<const char*> args = {
"imgdiff", "-z", "--block-limit=10", android::base::StringPrintf(
"--debug-dir=%s", debug_dir.path).c_str(), src_file.path, tgt_file.path, patch_file.path,
"imgdiff", "-z", "--block-limit=10", debug_dir_arg.c_str(), src_file.path, tgt_file.path,
patch_file.path,
};
ASSERT_EQ(0, imgdiff(args.size(), args.data()));

Expand Down Expand Up @@ -940,9 +942,10 @@ TEST(ImgdiffTest, zip_mode_large_enough_limit) {
// Compute patch with a limit of 20 blocks.
TemporaryFile patch_file;
TemporaryDir debug_dir;
std::string debug_dir_arg = android::base::StringPrintf("--debug-dir=%s", debug_dir.path);
std::vector<const char*> args = {
"imgdiff", "-z", "--block-limit=20", android::base::StringPrintf(
"--debug-dir=%s", debug_dir.path).c_str(), src_file.path, tgt_file.path, patch_file.path,
"imgdiff", "-z", "--block-limit=20", debug_dir_arg.c_str(), src_file.path, tgt_file.path,
patch_file.path,
};
ASSERT_EQ(0, imgdiff(args.size(), args.data()));

Expand Down

0 comments on commit ca5a071

Please sign in to comment.