From 53a8c6e1cf7df17c6dd35bec875f8767ba0740ee Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Wed, 13 Jun 2018 17:06:33 +0200 Subject: [PATCH] context: Make it clear why we copy the ids Signed-off-by: Maxime Ripard --- src/context.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/context.c b/src/context.c index 812f8e9..230837d 100644 --- a/src/context.c +++ b/src/context.c @@ -96,12 +96,19 @@ VAStatus SunxiCedrusCreateContext(VADriverContextP context, goto error; } + /* + * The surface_ids array has been allocated by the caller and + * we don't have any indication wrt its life time. Let's make sure + * its life span is under our control. + */ ids = malloc(surfaces_count * sizeof(VASurfaceID)); if (ids == NULL) { status = VA_STATUS_ERROR_ALLOCATION_FAILED; goto error; } + memcpy(ids, surfaces_ids, surfaces_count * sizeof(VASurfaceID)); + for (i = 0; i < surfaces_count; i++) { surface_object = SURFACE(surfaces_ids[i]); if (surface_object == NULL) { @@ -125,8 +132,6 @@ VAStatus SunxiCedrusCreateContext(VADriverContextP context, surface_object->destination_index = i; surface_object->source_data = source_data; surface_object->source_size = length; - - ids[i] = surfaces_ids[i]; } rc = v4l2_set_stream(driver_data->video_fd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, true);