about summary refs log tree commit diff
path: root/src/rt/rust_upcall.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rt/rust_upcall.cpp')
-rw-r--r--src/rt/rust_upcall.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp
index 12ef28065bd..65299a7d244 100644
--- a/src/rt/rust_upcall.cpp
+++ b/src/rt/rust_upcall.cpp
@@ -283,12 +283,14 @@ void upcall_s_free_shared_type_desc(type_desc *td)
     rust_task *task = rust_scheduler::get_task();
     LOG_UPCALL_ENTRY(task);
 
-    // Recursively free any referenced descriptors:
-    for (unsigned i = 0; i < td->n_params; i++) {
-        upcall_s_free_shared_type_desc((type_desc*) td->first_param[i]);
-    }
+    if (td) {
+        // Recursively free any referenced descriptors:
+        for (unsigned i = 0; i < td->n_params; i++) {
+            upcall_s_free_shared_type_desc((type_desc*) td->first_param[i]);
+        }
 
-    task->kernel->free(td);
+        task->kernel->free(td);
+    }
 }
 
 extern "C" CDECL void