{
struct pipe_reference *src_ref;
struct pipe_reference *dst_ref;
- struct vmw_svga_winsys_surface *dst = *pdst;
-
- if(*pdst == src || pdst == NULL)
+ struct vmw_svga_winsys_surface *dst;
+
+ if(pdst == NULL || *pdst == src)
return;
-
+
+ dst = *pdst;
+
src_ref = src ? &src->refcnt : NULL;
dst_ref = dst ? &dst->refcnt : NULL;
- if (pipe_reference(&dst_ref, src_ref)) {
+ if (pipe_reference(dst_ref, src_ref)) {
vmw_ioctl_surface_destroy(dst->screen, dst->sid);
#ifdef DEBUG
/* to detect dangling pointers */