[Bf-blender-cvs] [7359cc1060] master: Fix possible crash in various 3D View operators

Julian Eisel noreply at git.blender.org
Thu Feb 23 02:15:05 CET 2017


Commit: 7359cc1060e43bf094d471d5a4bdbd56f672ddbf
Author: Julian Eisel
Date:   Thu Feb 23 01:59:40 2017 +0100
Branches: master
https://developer.blender.org/rB7359cc1060e43bf094d471d5a4bdbd56f672ddbf

Fix possible crash in various 3D View operators

Was actually harmeless and not crashing, but I'd say more or less only
by luck: the NULL-check for region data would only evaluate to true for
the correct 3D View region. However, if we were to add region data to a
different region type in future, this would lead to undefined behavior
if executed in the wrong region.

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

M	source/blender/editors/space_view3d/space_view3d.c

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

diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 964f4bcdd9..e73cc507f3 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -180,8 +180,8 @@ bool ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_ar)
 		View3D *v3d = (View3D *)sa->spacedata.first;
 
 		if (ar) {
-			RegionView3D *rv3d = ar->regiondata;
-			if (rv3d && (rv3d->viewlock & RV3D_LOCKED) == 0) {
+			RegionView3D *rv3d;
+			if ((ar->regiontype == RGN_TYPE_WINDOW) && (rv3d = ar->regiondata) && (rv3d->viewlock & RV3D_LOCKED) == 0) {
 				*r_v3d = v3d;
 				*r_ar = ar;
 				return true;




More information about the Bf-blender-cvs mailing list