From: Nicholas Nethercote Date: Wed, 25 May 2005 21:30:05 +0000 (+0000) Subject: Avoid confusing use of a pointer before checking it it's NULL. (The X-Git-Tag: svn/VALGRIND_3_0_0~513 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43944db0d34c515185859e58ffb62d777cddb5ac;p=thirdparty%2Fvalgrind.git Avoid confusing use of a pointer before checking it it's NULL. (The code from the glibc demangler is buggy, but because we use a malloc() that never returns NULL, this code is actually ok within Valgrind, albeit strange. I changed it to avoid possible confusion.) Reported by Madhu Kurup. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3805 --- diff --git a/coregrind/m_demangle/cp-demangle.c b/coregrind/m_demangle/cp-demangle.c index 7bd5d4c703..591b95141b 100644 --- a/coregrind/m_demangle/cp-demangle.c +++ b/coregrind/m_demangle/cp-demangle.c @@ -413,9 +413,9 @@ string_list_new (length) int length; { string_list_t s = (string_list_t) malloc (sizeof (struct string_list_def)); - s->caret_position = 0; if (s == NULL) return NULL; + s->caret_position = 0; if (!dyn_string_init ((dyn_string_t) s, length)) return NULL; return s;