diff --git a/src/modules/replay/Replay.cpp b/src/modules/replay/Replay.cpp index 8869b0a153..cd4503a6e6 100644 --- a/src/modules/replay/Replay.cpp +++ b/src/modules/replay/Replay.cpp @@ -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; } diff --git a/src/systemcmds/bl_update/bl_update.c b/src/systemcmds/bl_update/bl_update.c index dd8012f416..d70d872c4c 100644 --- a/src/systemcmds/bl_update/bl_update.c +++ b/src/systemcmds/bl_update/bl_update.c @@ -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");