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
1 changed files with 4 additions and 0 deletions

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);