mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-23 16:23:56 -04:00
DataFlash_File: protect against fopen failing
This commit is contained in:
parent
15265a45ed
commit
ce84ba049f
@ -801,6 +801,10 @@ uint16_t DataFlash_File::start_new_log(void)
|
|||||||
// now update lastlog.txt with the new log number
|
// now update lastlog.txt with the new log number
|
||||||
fname = _lastlog_file_name();
|
fname = _lastlog_file_name();
|
||||||
FILE *f = ::fopen(fname, "w");
|
FILE *f = ::fopen(fname, "w");
|
||||||
|
if (f == NULL) {
|
||||||
|
free(fname);
|
||||||
|
return 0xFFFF;
|
||||||
|
}
|
||||||
fprintf(f, "%u\r\n", (unsigned)log_num);
|
fprintf(f, "%u\r\n", (unsigned)log_num);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
free(fname);
|
free(fname);
|
||||||
|
Loading…
Reference in New Issue
Block a user