From 58d74230d5fd6893d63fdfc5da8da4f68c7270be Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 14 Feb 2017 13:25:32 +1100 Subject: [PATCH] DataFlash: correct error detection for asprintf --- libraries/DataFlash/DataFlash_File.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/DataFlash/DataFlash_File.cpp b/libraries/DataFlash/DataFlash_File.cpp index 90a981ed72..c892040fd0 100644 --- a/libraries/DataFlash/DataFlash_File.cpp +++ b/libraries/DataFlash/DataFlash_File.cpp @@ -422,7 +422,7 @@ bool DataFlash_File::NeedPrep() char *DataFlash_File::_log_file_name(const uint16_t log_num) const { 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 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 *buf = nullptr; - if (asprintf(&buf, "%s/LASTLOG.TXT", _log_directory) == 0) { + if (asprintf(&buf, "%s/LASTLOG.TXT", _log_directory) == -1) { return nullptr; } return buf;