Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix segfaults (double free & color conversion) in darktable-chart #13281

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/chart/colorchart.c
Expand Up @@ -326,7 +326,6 @@ chart_t *parse_cht(const char *filename)
}

if(!first_label) first_label = label;
g_free(last_label);
last_label = label;

// store it
Expand Down Expand Up @@ -367,7 +366,6 @@ chart_t *parse_cht(const char *filename)
if(kl == 'X' || kl == 'Y')
g_hash_table_insert(result->patch_sets, g_strdup_printf("%s .. %s", first_label, last_label), labels);

g_free(last_label);
free(y_label);
free(x_label);
}
Expand Down
11 changes: 9 additions & 2 deletions src/chart/main.c
Expand Up @@ -1658,8 +1658,15 @@ static void image_lab_to_xyz(float *image, const int width, const int height)
for(int y = 0; y < height; y++)
for(int x = 0; x < width; x++)
{
float *pixel = &image[(x + y * width) * 3];
dt_Lab_to_XYZ(pixel, pixel);
const int i0 = (x + y * width) * 3 + 0;
const int i1 = (x + y * width) * 3 + 1;
const int i2 = (x + y * width) * 3 + 2;
dt_aligned_pixel_t pixel_lab = { image[i0], image[i1], image[i2] };
dt_aligned_pixel_t pixel_xyz = { 0.0 };
dt_Lab_to_XYZ(pixel_lab, pixel_xyz);
image[i0] = pixel_xyz[0];
image[i1] = pixel_xyz[1];
image[i2] = pixel_xyz[2];
}
}

Expand Down