st/vdpau: correct null check
authorThomas Hindoe Paaboel Andersen <phomes@gmail.com>
Wed, 30 Mar 2016 06:13:24 +0000 (08:13 +0200)
committerChristian König <christian.koenig@amd.com>
Wed, 30 Mar 2016 18:00:27 +0000 (20:00 +0200)
The null check of result was the wrong way around. Also, move memset
and dereference of result after the null check.

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

index 0550141b5973c927cc470ea16cc89422888926cd..d418d56a26aba0fb3a55b8e8517f33c2992323a3 100644 (file)
@@ -426,18 +426,18 @@ VdpStatus vlVdpVideoSurfaceDMABuf(VdpVideoSurface surface,
 
    struct pipe_surface *surf;
 
-   memset(result, 0, sizeof(*result));
-   result->handle = -1;
-
    if (!p_surf)
       return VDP_STATUS_INVALID_HANDLE;
 
    if (plane > 3)
       return VDP_STATUS_INVALID_VALUE;
 
-   if (result)
+   if (!result)
       return VDP_STATUS_INVALID_POINTER;
 
+   memset(result, 0, sizeof(*result));
+   result->handle = -1;
+
    pipe_mutex_lock(p_surf->device->mutex);
    if (p_surf->video_buffer == NULL) {
       struct pipe_context *pipe = p_surf->device->context;