Index: client/crash_report_database_win.cc |
diff --git a/client/crash_report_database_win.cc b/client/crash_report_database_win.cc |
index 7f4ede4f10bce43be51633b9ae6843b5b96892f5..fff340af906962f9c90da625f9402ca4a85292b8 100644 |
--- a/client/crash_report_database_win.cc |
+++ b/client/crash_report_database_win.cc |
@@ -417,26 +417,29 @@ void Metadata::Read() { |
return; |
} |
- std::vector<MetadataFileReportRecord> records(header.num_records); |
- if (!LoggingReadFile(handle_.get(), &records[0], records_size.ValueOrDie())) { |
- LOG(ERROR) << "failed to read records"; |
- return; |
- } |
- |
- std::string string_table = ReadRestOfFileAsString(handle_.get()); |
- if (string_table.empty() || string_table.back() != '\0') { |
- LOG(ERROR) << "bad string table"; |
- return; |
- } |
- |
std::vector<ReportDisk> reports; |
- for (const auto& record : records) { |
- if (record.file_path_index >= string_table.size() || |
- record.id_index >= string_table.size()) { |
- LOG(ERROR) << "invalid string table index"; |
+ if (header.num_records > 0) { |
+ std::vector<MetadataFileReportRecord> records(header.num_records); |
+ if (!LoggingReadFile( |
+ handle_.get(), &records[0], records_size.ValueOrDie())) { |
+ LOG(ERROR) << "failed to read records"; |
return; |
} |
- reports.push_back(ReportDisk(record, report_dir_, string_table)); |
+ |
+ std::string string_table = ReadRestOfFileAsString(handle_.get()); |
+ if (string_table.empty() || string_table.back() != '\0') { |
+ LOG(ERROR) << "bad string table"; |
+ return; |
+ } |
+ |
+ for (const auto& record : records) { |
+ if (record.file_path_index >= string_table.size() || |
+ record.id_index >= string_table.size()) { |
+ LOG(ERROR) << "invalid string table index"; |
+ return; |
+ } |
+ reports.push_back(ReportDisk(record, report_dir_, string_table)); |
+ } |
} |
reports_.swap(reports); |
} |
@@ -466,6 +469,9 @@ void Metadata::Write() { |
return; |
} |
+ if (num_records == 0) |
+ return; |
+ |
// Build the records and string table we're going to write. |
std::string string_table; |
std::vector<MetadataFileReportRecord> records; |