Mesa (master): util: Move dereference after null check in util_resource_copy_region.

Vinson Lee vlee at kemper.freedesktop.org
Sun Aug 5 04:41:53 UTC 2012


Module: Mesa
Branch: master
Commit: 3e7b3a04bf7667583dac18f1267d213aa7f33800
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3e7b3a04bf7667583dac18f1267d213aa7f33800

Author: Vinson Lee <vlee at freedesktop.org>
Date:   Fri Aug  3 23:38:29 2012 -0700

util: Move dereference after null check in util_resource_copy_region.

Fixes dereference before null check defect reported by Coverity.

Signed-off-by: Vinson Lee <vlee at freedesktop.org>
Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/gallium/auxiliary/util/u_surface.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c
index a541a38..fcfff14 100644
--- a/src/gallium/auxiliary/util/u_surface.c
+++ b/src/gallium/auxiliary/util/u_surface.c
@@ -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;
 




More information about the mesa-commit mailing list