View open merge request
Commits (1)
  • Benjamin Berg's avatar
    elan: Fix memory leak in elan_submit_image · 400cacf8
    Benjamin Berg authored
    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
......@@ -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);