ADSB retrieve_record just-in-case check (#1848)

This commit is contained in:
Mark Thompson 2024-02-05 13:13:06 -06:00 committed by GitHub
parent f2c008602d
commit bc035cff6a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View File

@ -199,6 +199,10 @@ ADSBRxAircraftDetailsView::ADSBRxAircraftDetailsView(
}
break;
case DATABASE_RECORD_NOT_FOUND:
// Defaults should be filled by the constructor
break;
case DATABASE_NOT_FOUND:
text_manufacturer.set("No icao24.db file");
break;

View File

@ -56,6 +56,9 @@ int database::retrieve_aircraft_record(AircraftDBRecord* record, std::string sea
}
int database::retrieve_record(std::string file_path, int index_item_length, int record_length, void* record, std::string search_term) {
if (search_term.empty())
return DATABASE_RECORD_NOT_FOUND;
auto result = db_file.open(file_path);
if (!result.is_valid()) {
number_of_records = (db_file.size() / (index_item_length + record_length)); // determine number of records in file