Browse Source

DataFlash: Avoid null pointer dereference

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

Should fix CID 126742
master
Murilo Belluzzo 9 years ago committed by Lucas De Marchi
parent
commit
e17fdb2aa9
  1. 5
      libraries/DataFlash/DataFlash.cpp

5
libraries/DataFlash/DataFlash.cpp

@ -351,6 +351,11 @@ bool DataFlash_Class::fill_log_write_logstructure(struct LogStructure &logstruct @@ -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));

Loading…
Cancel
Save