5
0
mirror of https://github.com/ArduPilot/ardupilot synced 2025-02-23 08:13:56 -04:00

DataFlash_File: protect against fopen failing

This commit is contained in:
Peter Barker 2015-12-08 23:18:37 +11:00 committed by Andrew Tridgell
parent 15265a45ed
commit ce84ba049f

View File

@ -801,6 +801,10 @@ uint16_t DataFlash_File::start_new_log(void)
// now update lastlog.txt with the new log number
fname = _lastlog_file_name();
FILE *f = ::fopen(fname, "w");
if (f == NULL) {
free(fname);
return 0xFFFF;
}
fprintf(f, "%u\r\n", (unsigned)log_num);
fclose(f);
free(fname);