Skip to content

Commit

Permalink
fix: transport memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Oct 21, 2024
1 parent 3a032cf commit f41e9f7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/transport/multicast/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ void *_zp_multicast_read_task(void *ztm_arg) {
_z_slice_clear(&addr);
} else {
_Z_ERROR("Dropping message due to processing error: %d", ret);
_z_slice_clear(&addr);
continue;
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/transport/multicast/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ z_result_t _z_multicast_handle_transport_message(_z_transport_multicast_t *ztm,
uint16_t mapping = entry->_peer_id;
_z_msg_fix_mapping(&zm, mapping);
_z_handle_network_message(ztm->_session, &zm, mapping);
// Fragmented messages must be cleared. Non-fragmented messages are released with their transport.
_z_msg_clear(&zm);
} else {
_Z_INFO("Failed to decode defragmented message");
ret = _Z_ERR_MESSAGE_DESERIALIZATION_FAILED;
}
// Fragmented messages must be cleared. Non-fragmented messages are released with their transport.
_z_msg_clear(&zm);
// Free the decoding buffer
_z_zbuf_clear(&zbf);
*dbuf_state = _Z_DBUF_STATE_NULL;
Expand Down
4 changes: 2 additions & 2 deletions src/transport/unicast/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ z_result_t _z_unicast_handle_transport_message(_z_transport_unicast_t *ztu, _z_t
zm._reliability = _z_t_msg_get_reliability(t_msg);
if (ret == _Z_RES_OK) {
_z_handle_network_message(ztu->_session, &zm, _Z_KEYEXPR_MAPPING_UNKNOWN_REMOTE);
// Fragmented messages must be cleared. Non-fragmented messages are released with their transport.
_z_msg_clear(&zm);
} else {
_Z_INFO("Failed to decode defragmented message");
ret = _Z_ERR_MESSAGE_DESERIALIZATION_FAILED;
}
// Fragmented messages must be cleared. Non-fragmented messages are released with their transport.
_z_msg_clear(&zm);
// Free the decoding buffer
_z_zbuf_clear(&zbf);
*dbuf_state = _Z_DBUF_STATE_NULL;
Expand Down

0 comments on commit f41e9f7

Please sign in to comment.