[Bf-blender-cvs] [b506f3d] master: Cycles: Add assert to an array at() function to be sure we don't have bad memory access

Sergey Sharybin noreply at git.blender.org
Sun Jun 28 18:15:39 CEST 2015


Commit: b506f3d3280c08b2b8817ab9aaf7f8ff803eb2ec
Author: Sergey Sharybin
Date:   Sun Jun 28 11:18:48 2015 +0200
Branches: master
https://developer.blender.org/rBb506f3d3280c08b2b8817ab9aaf7f8ff803eb2ec

Cycles: Add assert to an array at() function to be sure we don't have bad memory access

===================================================================

M	intern/cycles/util/util_vector.h

===================================================================

diff --git a/intern/cycles/util/util_vector.h b/intern/cycles/util/util_vector.h
index 6f718b1..15a65be 100644
--- a/intern/cycles/util/util_vector.h
+++ b/intern/cycles/util/util_vector.h
@@ -19,7 +19,8 @@
 
 /* Vector */
 
-#include <string.h>
+#include <cassert>
+#include <cstring>
 #include <vector>
 
 #include "util_aligned_malloc.h"
@@ -187,6 +188,7 @@ public:
 
 	T& operator[](size_t i) const
 	{
+		assert(i < datasize);
 		return data[i];
 	}




More information about the Bf-blender-cvs mailing list