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;
}
&uiter)) != -ENOENT) {
health_code_update(&health_thread_cmd);
if (count >= nbmem) {
+ /* In case the realloc fails, we free the memory */
+ void *tmp_ptr = (void *) tmp;
DBG2("Reallocating event list from %zu to %zu entries", nbmem,
2 * nbmem);
nbmem *= 2;
tmp = realloc(tmp, nbmem * sizeof(struct lttng_event));
if (tmp == NULL) {
PERROR("realloc ust app events");
+ free(tmp_ptr);
ret = -ENOMEM;
goto rcu_error;
}
&uiter)) != -ENOENT) {
health_code_update(&health_thread_cmd);
if (count >= nbmem) {
+ /* In case the realloc fails, we free the memory */
+ void *tmp_ptr = (void *) tmp;
DBG2("Reallocating event field list from %zu to %zu entries", nbmem,
2 * nbmem);
nbmem *= 2;
tmp = realloc(tmp, nbmem * sizeof(struct lttng_event_field));
if (tmp == NULL) {
PERROR("realloc ust app event fields");
+ free(tmp_ptr);
ret = -ENOMEM;
goto rcu_error;
}