aboutsummaryrefslogtreecommitdiff
path: root/games/gtkradiant/files/patch-radiant_treemodel.cpp
blob: 8663dfac8ad56df884970951cef9c87c00551e01 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
--- radiant/treemodel.cpp.orig	2006-02-10 22:01:20 UTC
+++ radiant/treemodel.cpp
@@ -710,7 +710,13 @@ public:
 
 void node_attach_name_changed_callback(scene::Node& node, const NameCallback& callback)
 {
-  if(&node != 0)
+  // Reference cannot be bound to dereferenced null pointer in well-defined
+  // C++ code, and Clang will assume that comparison below always evaluates
+  // to true, resulting in a segmentation fault.  Use a dirty hack to force
+  // Clang to check those "bad" references for null nonetheless.
+  volatile intptr_t n = (intptr_t)&node;
+
+  if(n != 0)
   {
     Nameable* nameable = Node_getNameable(node);
     if(nameable != 0)
@@ -721,7 +727,9 @@ void node_attach_name_changed_callback(s
 }
 void node_detach_name_changed_callback(scene::Node& node, const NameCallback& callback)
 {
-  if(&node != 0)
+  volatile intptr_t n = (intptr_t)&node;		// see the comment on line 713
+
+  if(n != 0)
   {
     Nameable* nameable = Node_getNameable(node);
     if(nameable != 0)
@@ -1243,7 +1251,9 @@ const char* node_get_name(scene::Node& n
 
 const char* node_get_name_safe(scene::Node& node)
 {
-  if(&node == 0)
+  volatile intptr_t n = (intptr_t)&node;		// see the comment on line 713
+
+  if(n == 0)
   {
     return "";
   }
@@ -1264,7 +1274,9 @@ GraphTreeNode* graph_tree_model_find_par
 
 void node_attach_name_changed_callback(scene::Node& node, const NameCallback& callback)
 {
-  if(&node != 0)
+  volatile intptr_t n = (intptr_t)&node;		// see the comment on line 713
+
+  if(n != 0)
   {
     Nameable* nameable = Node_getNameable(node);
     if(nameable != 0)
@@ -1275,7 +1287,9 @@ void node_attach_name_changed_callback(s
 }
 void node_detach_name_changed_callback(scene::Node& node, const NameCallback& callback)
 {
-  if(&node != 0)
+  volatile intptr_t n = (intptr_t)&node;		// see the comment on line 713
+
+  if(n != 0)
   {
     Nameable* nameable = Node_getNameable(node);
     if(nameable != 0)