@@ -53,7 +53,7 @@ OGSubgraphRef OGSubgraphCreate(OGGraphRef cf_graph) {
53
53
OGSubgraphRef OGSubgraphCreate2 (OGGraphRef cf_graph, OGAttribute attribute) {
54
54
OG::Graph::Context &context = OG::Graph::Context::from_cf (cf_graph);
55
55
const CFIndex extraSize = sizeof (OGSubgraphStorage)-sizeof (CFRuntimeBase);
56
- #if TARGET_CPU_WASM32
56
+ #if OG_TARGET_CPU_WASM32
57
57
// FIXME: extraSize will always be 8 thus it will fail on WASM. Investate later.
58
58
static_assert (extraSize == 8 );
59
59
#else
@@ -67,15 +67,15 @@ OGSubgraphRef OGSubgraphCreate2(OGGraphRef cf_graph, OGAttribute attribute) {
67
67
return cf_subgrah;
68
68
}
69
69
70
- OGSubgraphRef OGSubgraphGetCurrent () {
70
+ _Nullable OGSubgraphRef OGSubgraphGetCurrent () {
71
71
OG::Subgraph* subgraph = (OG::Subgraph*)pthread_getspecific (OG::Subgraph::current_key ());
72
72
if (subgraph == nullptr ) {
73
73
return nullptr ;
74
74
}
75
75
return subgraph->to_cf ();
76
76
}
77
77
78
- void OGSubgraphSetCurrent (OGSubgraphRef cf_subgraph) {
78
+ void OGSubgraphSetCurrent (_Nullable OGSubgraphRef cf_subgraph) {
79
79
OG::Subgraph* oldSubgraph = (OG::Subgraph*)pthread_getspecific (OG::Subgraph::current_key ());
80
80
if (cf_subgraph == nullptr ) {
81
81
pthread_setspecific (OG::Subgraph::current_key (), nullptr );
@@ -86,7 +86,10 @@ void OGSubgraphSetCurrent(OGSubgraphRef cf_subgraph) {
86
86
}
87
87
}
88
88
if (oldSubgraph != nullptr ) {
89
- CFRelease (oldSubgraph->to_cf ());
89
+ OGSubgraphRef cf_oldSubgraph = oldSubgraph->to_cf ();
90
+ if (cf_oldSubgraph) {
91
+ CFRelease (cf_oldSubgraph);
92
+ }
90
93
}
91
94
}
92
95
0 commit comments