util: Move dereference after null check in util_resource_copy_region.
authorVinson Lee <vlee@freedesktop.org>
Sat, 4 Aug 2012 06:38:29 +0000 (23:38 -0700)
committerVinson Lee <vlee@freedesktop.org>
Sun, 5 Aug 2012 04:41:27 +0000 (21:41 -0700)
Fixes dereference before null check defect reported by Coverity.

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/auxiliary/util/u_surface.c

index a541a38ffa1696d7586070fbb64db69b3701cd9b..fcfff148fe40dc76490d6f35d2c416080827d539 100644 (file)
@@ -160,12 +160,12 @@ util_resource_copy_region(struct pipe_context *pipe,
    unsigned h = src_box->height;
 
    assert(src && dst);
-   assert((src->target == PIPE_BUFFER && dst->target == PIPE_BUFFER) ||
-          (src->target != PIPE_BUFFER && dst->target != PIPE_BUFFER));
-
    if (!src || !dst)
       return;
 
+   assert((src->target == PIPE_BUFFER && dst->target == PIPE_BUFFER) ||
+          (src->target != PIPE_BUFFER && dst->target != PIPE_BUFFER));
+
    src_format = src->format;
    dst_format = dst->format;