[Mesa-dev] [RFC 4/7] nir/array: fix empty-iterator coverity warning
Rob Clark
robdclark at gmail.com
Wed May 18 15:54:12 UTC 2016
From: Rob Clark <robclark at freedesktop.org>
For example, at nir_lower_locals_to_regs.c:365:
CID 1358911 (#1 of 1): Explicit null dereferenced (FORWARD_NULL)7.
var_deref_op: Dereferencing null pointer deref_ptr.
I'm pretty sure that coverity doesn't understand the relationship
between arr->data and arr->size. I think throwing in a !null check
should do the trick.
---
src/compiler/nir/nir_array.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/compiler/nir/nir_array.h b/src/compiler/nir/nir_array.h
index 1db4e8c..2f57833 100644
--- a/src/compiler/nir/nir_array.h
+++ b/src/compiler/nir/nir_array.h
@@ -89,7 +89,7 @@ nir_array_grow(nir_array *arr, size_t additional)
#define nir_array_foreach(arr, type, elem) \
for (type *elem = (type *)(arr)->data; \
- elem < (type *)((char *)(arr)->data + (arr)->size); elem++)
+ elem && (elem < (type *)((char *)(arr)->data + (arr)->size)); elem++)
#ifdef __cplusplus
} /* extern "C" */
--
2.5.5
More information about the mesa-dev
mailing list