Skip to content

Commit

Permalink
encoder: opentelemetry: addressed previously missed leaks
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Alminana <[email protected]>
  • Loading branch information
leonardo-albertovich committed Dec 17, 2024
1 parent 9c0b748 commit d7c0105
Showing 1 changed file with 38 additions and 12 deletions.
50 changes: 38 additions & 12 deletions src/cprof_encode_opentelemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,8 @@ static void destroy_location(
for (index = 0 ; index < instance->n_line ; index++) {
destroy_line(instance->line[index]);
}

free(instance->line);
}

if (instance->attributes != NULL) {
Expand Down Expand Up @@ -758,28 +760,48 @@ static void destroy_profile(
size_t index;

if (instance != NULL) {
for (index = 0 ; index < instance->n_sample_type ; index++) {
destroy_value_type(instance->sample_type[index]);
if (instance->sample_type != NULL) {
for (index = 0 ; index < instance->n_sample_type ; index++) {
destroy_value_type(instance->sample_type[index]);
}

free(instance->sample_type);
}

for (index = 0 ; index < instance->n_sample ; index++) {
destroy_sample(instance->sample[index]);
if (instance->sample != NULL) {
for (index = 0 ; index < instance->n_sample ; index++) {
destroy_sample(instance->sample[index]);
}

free(instance->sample);
}

for (index = 0 ; index < instance->n_mapping ; index++) {
destroy_mapping(instance->mapping[index]);
if (instance->mapping != NULL) {
for (index = 0 ; index < instance->n_mapping ; index++) {
destroy_mapping(instance->mapping[index]);
}

free(instance->mapping);
}

for (index = 0 ; index < instance->n_location ; index++) {
destroy_location(instance->location[index]);
if (instance->location != NULL) {
for (index = 0 ; index < instance->n_location ; index++) {
destroy_location(instance->location[index]);
}

free(instance->location);
}

if (instance->location_indices != NULL) {
free(instance->location_indices);
}

for (index = 0 ; index < instance->n_function ; index++) {
destroy_function(instance->function[index]);
if (instance->function != NULL) {
for (index = 0 ; index < instance->n_function ; index++) {
destroy_function(instance->function[index]);
}

free(instance->function);
}

if (instance->attribute_table != NULL) {
Expand All @@ -790,8 +812,12 @@ static void destroy_profile(
destroy_attribute_unit(instance->attribute_units[index]);
}

for (index = 0 ; index < instance->n_link_table ; index++) {
destroy_link(instance->link_table[index]);
if (instance->link_table != NULL) {
for (index = 0 ; index < instance->n_link_table ; index++) {
destroy_link(instance->link_table[index]);
}

free(instance->link_table);
}

if (instance->string_table != NULL) {
Expand Down

0 comments on commit d7c0105

Please sign in to comment.