Skip to content

Commit

Permalink
Merge pull request google#52 from gburgessiv/master
Browse files Browse the repository at this point in the history
Fix path truncation in profile_creator
  • Loading branch information
danielcdh authored Sep 7, 2017
2 parents 153c178 + 39d436b commit 58edc85
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions profile_creator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,17 @@ bool ProfileCreator::CreateProfile(const string &input_profile_name,
bool ProfileCreator::ReadSample(const string &input_profile_name,
const string &profiler) {
if (profiler == "perf") {
// Sets the regular expression to filter samples for a given binary.
char *dup_name = strdup(binary_.c_str());
char *strip_ptr = strstr(dup_name, ".unstripped");
if (strip_ptr) {
*strip_ptr = 0;
string file_base_name = basename(binary_.c_str());
size_t unstripped_at = file_base_name.find(".unstripped");
if (unstripped_at != string::npos) {
file_base_name.erase(unstripped_at);
}
const char *file_base_name = basename(dup_name);
CHECK(file_base_name) << "Cannot find basename for: " << binary_;
CHECK(!file_base_name.empty()) << "Cannot find basename for: " << binary_;

ElfReader reader(binary_);

sample_reader_ = new PerfDataSampleReader(
input_profile_name, file_base_name);
free(dup_name);
input_profile_name, std::move(file_base_name));
} else if (profiler == "text") {
sample_reader_ = new TextSampleReaderWriter(input_profile_name);
} else {
Expand Down

0 comments on commit 58edc85

Please sign in to comment.