]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Stack registration stuff: don't dereference NULL pointers (Eric
authorJulian Seward <jseward@acm.org>
Sat, 17 Nov 2007 02:05:57 +0000 (02:05 +0000)
committerJulian Seward <jseward@acm.org>
Sat, 17 Nov 2007 02:05:57 +0000 (02:05 +0000)
Sharkey, #150044).

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7171

coregrind/m_stacks.c

index 8400a6c8d61ee3676ececad80f7fdca73aa69c2b..90646595ac036fcff66f6937b03e6b86a17089f5 100644 (file)
@@ -154,7 +154,7 @@ void VG_(deregister_stack)(UWord id)
 
    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 @@ void VG_(unknown_SP_update)( Addr old_SP, Addr new_SP )
    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;