st/va: Fix vaSyncSurface with no outstanding operation
authorMark Thompson <sw@jkqxz.net>
Mon, 26 Sep 2016 22:22:31 +0000 (23:22 +0100)
committerChristian König <christian.koenig@amd.com>
Tue, 27 Sep 2016 12:21:44 +0000 (14:21 +0200)
Fixes crash if the application doesn't do what the state tracker expects.

Reviewed-by: Christian König <christian.koenig@amd.com>
src/gallium/state_trackers/va/surface.c

index 115db43f79103aaefe0012f63d512ce39b8b7a87..173e7d91ac6bad61e7da68800d0086a1a4ddaeeb 100644 (file)
@@ -111,6 +111,12 @@ vlVaSyncSurface(VADriverContextP ctx, VASurfaceID render_target)
       return VA_STATUS_ERROR_INVALID_SURFACE;
    }
 
+   if (!surf->feedback) {
+      // No outstanding operation: nothing to do.
+      pipe_mutex_unlock(drv->mutex);
+      return VA_STATUS_SUCCESS;
+   }
+
    context = handle_table_get(drv->htab, surf->ctx);
    if (!context) {
       pipe_mutex_unlock(drv->mutex);
@@ -126,6 +132,7 @@ vlVaSyncSurface(VADriverContextP ctx, VASurfaceID render_target)
       if (frame_diff < 2)
          context->decoder->flush(context->decoder);
       context->decoder->get_feedback(context->decoder, surf->feedback, &(surf->coded_buf->coded_size));
+      surf->feedback = NULL;
    }
    pipe_mutex_unlock(drv->mutex);
    return VA_STATUS_SUCCESS;