mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 02:03:34 +08:00
fix memory bugs in replay and bl_update
This commit is contained in:
@@ -416,11 +416,13 @@ Replay::readAndAddSubscription(std::ifstream &file, uint16_t msg_size)
|
||||
bool timestamp_found = findFieldOffset(orb_meta->o_fields, "timestamp", subscription->timestamp_offset, field_size);
|
||||
|
||||
if (!timestamp_found) {
|
||||
delete subscription;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (field_size != 8) {
|
||||
PX4_ERR("Unsupported timestamp with size %i, ignoring the topic %s", field_size, orb_meta->o_name);
|
||||
delete subscription;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -429,6 +431,7 @@ Replay::readAndAddSubscription(std::ifstream &file, uint16_t msg_size)
|
||||
subscription->next_read_pos = this_message_pos; //this will be skipped
|
||||
|
||||
if (!nextDataMessage(file, *subscription, msg_id)) {
|
||||
delete subscription;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -436,6 +439,7 @@ Replay::readAndAddSubscription(std::ifstream &file, uint16_t msg_size)
|
||||
|
||||
if (!subscription->orb_meta) {
|
||||
//no message found. This is not a fatal error
|
||||
delete subscription;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +142,6 @@ bl_update_main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
uint8_t *buf = malloc(image_size);
|
||||
memset(buf, 0xff, image_size);
|
||||
|
||||
if (buf == NULL)
|
||||
{
|
||||
@@ -151,6 +150,8 @@ bl_update_main(int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
memset(buf, 0xff, image_size);
|
||||
|
||||
if (read(fd, buf, file_size) != file_size)
|
||||
{
|
||||
PX4_ERR("firmware read error");
|
||||
|
||||
Reference in New Issue
Block a user