payload_size -= sizeof(struct lttcomm_relayd_metadata_payload);
if (data_buffer_size < data_size) {
+ /* In case the realloc fails, we can free the memory */
+ char *tmp_data_ptr = data_buffer;
data_buffer = realloc(data_buffer, data_size);
if (!data_buffer) {
ERR("Allocating data buffer");
+ free(tmp_data_ptr);
ret = -1;
goto end;
}
data_size = be32toh(data_hdr.data_size);
if (data_buffer_size < data_size) {
+ char *tmp_data_ptr = data_buffer;
data_buffer = realloc(data_buffer, data_size);
if (!data_buffer) {
ERR("Allocating data buffer");
+ free(tmp_data_ptr);
ret = -1;
goto end_unlock;
}