Compare commits

...

1 commit

Author SHA1 Message Date
Benjamin Berg
400cacf867 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
elan_dev_reset.
2019-06-18 22:36:38 +02:00

View file

@ -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;
G_DEBUG_HERE();
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,
&frames);
fpi_do_movement_estimation(&assembling_ctx, frames,
elandev->num_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);