From b16a9a984a23ec607ec652286df8bd60ada83047 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Mon, 29 Aug 2011 15:25:59 -0700 Subject: [PATCH] rt: Don't dereference a null pointer when traversing a function with no environment --- src/rt/rust_shape.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rt/rust_shape.h b/src/rt/rust_shape.h index 2ce4fcb5645..e568d480164 100644 --- a/src/rt/rust_shape.h +++ b/src/rt/rust_shape.h @@ -868,11 +868,12 @@ data::walk_fn_contents(bool align, ptr &dp) { dp += sizeof(void *); // Skip over the code pointer. uint8_t *box_ptr = bump_dp(dp); + if (!box_ptr) + return; + type_desc *subtydesc = *reinterpret_cast(box_ptr + sizeof(void *)); ptr closure_dp(box_ptr + sizeof(void *)); - if (!box_ptr) - return; arena arena; type_param *params = type_param::from_fn_shape(subtydesc->shape,