VG_(debugLog)(2, "stacks", "deregister stack %lu\n", id);
- if (current_stack->id == id) {
+ if (current_stack && current_stack->id == id) {
current_stack = NULL;
}
if (current_stack == NULL ||
new_SP < current_stack->start || new_SP > current_stack->end) {
Stack* new_stack = find_stack_by_addr(new_SP);
- if (new_stack && new_stack->id != current_stack->id) {
+ if (new_stack
+ && (current_stack == NULL || new_stack->id != current_stack->id)) {
/* The stack pointer is now in another stack. Update the current
stack information and return without doing anything else. */
current_stack = new_stack;