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.
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.
Replace tabs with spaces
auto merge of #7033 : influenza/rust/rust-7022, r=graydon

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.