Commit 400cacf8 authored by Benjamin Berg's avatar Benjamin Berg

elan: Fix memory leak in elan_submit_image

elan_submit_image would modify the list of received frames in place,
without freeing the associated memory. Fix this by using a local
variable so that the list remains unmodified and is fully released by
parent 4cec2841
Pipeline #43455 passed with stages
in 4 minutes and 33 seconds
......@@ -293,23 +293,24 @@ static void elan_process_frame_thirds(unsigned short *raw_frame,
static void elan_submit_image(struct fp_img_dev *dev)
struct elan_dev *elandev = FP_INSTANCE_DATA(FP_DEV(dev));
GSList *input_frames;
GSList *frames = NULL;
struct fp_img *img;
input_frames = elandev->frames;
for (int i = 0; i < ELAN_SKIP_LAST_FRAMES; i++)
elandev->frames = g_slist_next(elandev->frames);
elandev->num_frames -= ELAN_SKIP_LAST_FRAMES;
input_frames = g_slist_next (input_frames);
assembling_ctx.frame_width = elandev->frame_width;
assembling_ctx.frame_height = elandev->frame_height;
assembling_ctx.image_width = elandev->frame_width * 3 / 2;
g_slist_foreach(elandev->frames, (GFunc) elandev->process_frame,
g_slist_foreach(input_frames, (GFunc) elandev->process_frame,
fpi_do_movement_estimation(&assembling_ctx, frames,
img = fpi_assemble_frames(&assembling_ctx, frames, elandev->num_frames);
img = fpi_assemble_frames(&assembling_ctx, frames, elandev->num_frames - ELAN_SKIP_LAST_FRAMES);
img->flags |= FP_IMG_PARTIAL;
fpi_imgdev_image_captured(dev, img);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment