[Mesa-dev] [PATCH 4/5] gallium/auxiliary: fix member access within null pointer

Bartosz Tomczyk bartosz.tomczyk86 at gmail.com
Tue Feb 7 18:34:22 UTC 2017


---
 src/gallium/auxiliary/pipebuffer/pb_buffer.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer.h b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
index 33c23068c2..12c9ca779a 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
@@ -233,14 +233,16 @@ pb_destroy(struct pb_buffer *buf)
 }
 
 static inline void
-pb_reference(struct pb_buffer **dst,
+pb_reference(struct pb_buffer **pptr,
              struct pb_buffer *src)
 {
-   struct pb_buffer *old = *dst;
+   struct pb_buffer *dst = pptr ? *pptr : NULL;
+   struct pb_buffer *old = dst;
 
-   if (pipe_reference(&(*dst)->reference, &src->reference))
+   if (pipe_reference(dst ? &dst->reference : NULL,
+                      src ? &src->reference : NULL))
       pb_destroy( old );
-   *dst = src;
+   if (pptr) *pptr = src;
 }
 
 
-- 
2.11.1



More information about the mesa-dev mailing list