DataFlash: correct error detection for asprintf

This commit is contained in:
Peter Barker 2017-02-14 13:25:32 +11:00 committed by Andrew Tridgell
parent 794f7a969e
commit 58d74230d5

View File

@ -422,7 +422,7 @@ bool DataFlash_File::NeedPrep()
char *DataFlash_File::_log_file_name(const uint16_t log_num) const char *DataFlash_File::_log_file_name(const uint16_t log_num) const
{ {
char *buf = nullptr; char *buf = nullptr;
if (asprintf(&buf, "%s/%u.BIN", _log_directory, (unsigned)log_num) == 0) { if (asprintf(&buf, "%s/%u.BIN", _log_directory, (unsigned)log_num) == -1) {
return nullptr; return nullptr;
} }
return buf; return buf;
@ -435,7 +435,7 @@ char *DataFlash_File::_log_file_name(const uint16_t log_num) const
char *DataFlash_File::_lastlog_file_name(void) const char *DataFlash_File::_lastlog_file_name(void) const
{ {
char *buf = nullptr; char *buf = nullptr;
if (asprintf(&buf, "%s/LASTLOG.TXT", _log_directory) == 0) { if (asprintf(&buf, "%s/LASTLOG.TXT", _log_directory) == -1) {
return nullptr; return nullptr;
} }
return buf; return buf;