Stack registration stuff: don't dereference NULL pointers (Eric
Sharkey, #150044).



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7171 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_stacks.c b/coregrind/m_stacks.c
index 8400a6c..9064659 100644
--- a/coregrind/m_stacks.c
+++ b/coregrind/m_stacks.c
@@ -154,7 +154,7 @@
 
    VG_(debugLog)(2, "stacks", "deregister stack %lu\n", id);
 
-   if (current_stack->id == id) {
+   if (current_stack && current_stack->id == id) { 
       current_stack = NULL;
    }
 
@@ -209,7 +209,8 @@
    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;