DataFlash: Avoid null pointer dereference

Confirms that the loop successfully found a log structure before using it.

Should fix CID 126742
This commit is contained in:
Murilo Belluzzo 2016-08-02 18:36:54 -03:00 committed by Lucas De Marchi
parent 595aea236a
commit e17fdb2aa9

View File

@ -351,6 +351,11 @@ bool DataFlash_Class::fill_log_write_logstructure(struct LogStructure &logstruct
break;
}
}
if (!f) {
return false;
}
logstruct.msg_type = msg_type;
strncpy((char*)logstruct.name, f->name, sizeof(logstruct.name)); /* cast away the "const" (*gulp*) */
strncpy((char*)logstruct.format, f->fmt, sizeof(logstruct.format));