[Bf-blender-cvs] [919a665] master: Cycles: Avoid memcpy of intersecting memory

Sergey Sharybin noreply at git.blender.org
Fri Mar 20 17:16:36 CET 2015


Commit: 919a6654974f40c553ba30a4aba89e9d02251246
Author: Sergey Sharybin
Date:   Fri Mar 20 21:14:50 2015 +0500
Branches: master
https://developer.blender.org/rB919a6654974f40c553ba30a4aba89e9d02251246

Cycles: Avoid memcpy of intersecting memory

Could happen when assignment happens to self during sorting.

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

M	intern/cycles/bvh/bvh_params.h

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

diff --git a/intern/cycles/bvh/bvh_params.h b/intern/cycles/bvh/bvh_params.h
index 99bfd94..af8d8ee 100644
--- a/intern/cycles/bvh/bvh_params.h
+++ b/intern/cycles/bvh/bvh_params.h
@@ -113,7 +113,9 @@ public:
 	__forceinline int prim_type() const { return type; }
 
 	BVHReference& operator=(const BVHReference &arg) {
-		memcpy(this, &arg, sizeof(BVHReference));
+		if(&arg != this) {
+			memcpy(this, &arg, sizeof(BVHReference));
+		}
 		return *this;
 	}




More information about the Bf-blender-cvs mailing list