Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: client/crash_report_database_win.cc

Issue 1492503002: win: Fix debug iterator failure on empty database read/write (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: reading too Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/crash_report_database_test.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « client/crash_report_database_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698