From: Julian Seward Date: Sat, 17 Nov 2007 02:05:57 +0000 (+0000) Subject: Stack registration stuff: don't dereference NULL pointers (Eric X-Git-Tag: svn/VALGRIND_3_3_0~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb12a8770d94fac2e06c5b6b0ba71ee47c39ef02;p=thirdparty%2Fvalgrind.git Stack registration stuff: don't dereference NULL pointers (Eric Sharkey, #150044). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7171 --- diff --git a/coregrind/m_stacks.c b/coregrind/m_stacks.c index 8400a6c8d6..90646595ac 100644 --- a/coregrind/m_stacks.c +++ b/coregrind/m_stacks.c @@ -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;