Skip to content
Snippets Groups Projects
Commit 5c12fc2e authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Fix memory leak and uninitialized acces in sixel graphics.

Properly initialize sixel mask width/height.
Free sx_mask->bits when finished.

These were broken by the PPM feature commit 4975b416
parent c1ccc108
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #4296 passed
...@@ -1687,6 +1687,8 @@ static void parse_sixel_string(struct cterminal *cterm, bool finish) ...@@ -1687,6 +1687,8 @@ static void parse_sixel_string(struct cterminal *cterm, bool finish)
cterm->sx_pixels->width = ti.screenwidth * vparams[vmode].charwidth; cterm->sx_pixels->width = ti.screenwidth * vparams[vmode].charwidth;
cterm->sx_pixels->height = cterm->sx_iv * 6; cterm->sx_pixels->height = cterm->sx_iv * 6;
cterm->sx_mask = malloc(sizeof(struct ciolib_mask)); cterm->sx_mask = malloc(sizeof(struct ciolib_mask));
cterm->sx_mask->width = cterm->sx_pixels->width;
cterm->sx_mask->height = cterm->sx_pixels->height;
cterm->sx_mask->bits = malloc((cterm->sx_iv * 6 * ti.screenwidth * vparams[vmode].charwidth * 6 + 7)/8); cterm->sx_mask->bits = malloc((cterm->sx_iv * 6 * ti.screenwidth * vparams[vmode].charwidth * 6 + 7)/8);
memset(cterm->sx_mask->bits, 0, (cterm->sx_iv * 6 * ti.screenwidth * vparams[vmode].charwidth * 6 + 7)/8); memset(cterm->sx_mask->bits, 0, (cterm->sx_iv * 6 * ti.screenwidth * vparams[vmode].charwidth * 6 + 7)/8);
} }
...@@ -1896,6 +1898,8 @@ all_done: ...@@ -1896,6 +1898,8 @@ all_done:
cterm->sixel = SIXEL_INACTIVE; cterm->sixel = SIXEL_INACTIVE;
if (cterm->sx_pixels) if (cterm->sx_pixels)
FREE_AND_NULL(cterm->sx_pixels->pixels); FREE_AND_NULL(cterm->sx_pixels->pixels);
if (cterm->sx_mask)
FREE_AND_NULL(cterm->sx_mask->bits);
FREE_AND_NULL(cterm->sx_pixels); FREE_AND_NULL(cterm->sx_pixels);
FREE_AND_NULL(cterm->sx_mask); FREE_AND_NULL(cterm->sx_mask);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment