From 12203a76c22cebff394a2b157a0d1f4cec3d46f8 Mon Sep 17 00:00:00 2001 From: Ron Dahlgren Date: Sat, 8 Jun 2013 22:16:14 -0700 Subject: Check stk before dereferencing This commit fixes #7022 - I've added an additional check to ensure that stk is not null before dereferencing it to get it's next element, assigning NULL if it is itself NULL. --- src/rt/rust_task.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index b5ecb166175..c521feae72f 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -612,7 +612,7 @@ rust_task::new_big_stack() { } big_stack->task = this; - big_stack->next = stk->next; + big_stack->next = stk ? stk->next : NULL; if (big_stack->next) big_stack->next->prev = big_stack; big_stack->prev = stk; -- cgit 1.4.1-3-g733a5 From 301f9001c01ffbca89241dcd8c0c2f1ae6928dfd Mon Sep 17 00:00:00 2001 From: Ron Dahlgren Date: Tue, 11 Jun 2013 10:11:49 -0700 Subject: Assert stk rather than checking null Given that a big stack is never requested before allocating an initial stack segment, having a non-null stk member here is an invariant. --- src/rt/rust_task.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index c521feae72f..befcf149936 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -587,6 +587,7 @@ rust_task::cleanup_after_turn() { // stack and false otherwise. bool rust_task::new_big_stack() { + assert(stk); // If we have a cached big stack segment, use it. if (big_stack) { // Check to see if we're already on the big stack. @@ -612,12 +613,11 @@ rust_task::new_big_stack() { } big_stack->task = this; - big_stack->next = stk ? stk->next : NULL; + big_stack->next = stk->next; if (big_stack->next) big_stack->next->prev = big_stack; big_stack->prev = stk; - if (stk) - stk->next = big_stack; + stk->next = big_stack; stk = big_stack; -- cgit 1.4.1-3-g733a5 From 37c855889586754ddd2e19147a40c92450ddadec Mon Sep 17 00:00:00 2001 From: Ron Dahlgren Date: Tue, 11 Jun 2013 13:10:41 -0700 Subject: Replace tabs with spaces --- src/rt/rust_task.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index befcf149936..f9b588b7850 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -587,7 +587,7 @@ rust_task::cleanup_after_turn() { // stack and false otherwise. bool rust_task::new_big_stack() { - assert(stk); + assert(stk); // If we have a cached big stack segment, use it. if (big_stack) { // Check to see if we're already on the big stack. @@ -617,7 +617,7 @@ rust_task::new_big_stack() { if (big_stack->next) big_stack->next->prev = big_stack; big_stack->prev = stk; - stk->next = big_stack; + stk->next = big_stack; stk = big_stack; -- cgit 1.4.1-3-g733a5