From: Tom Hughes Date: Wed, 6 Jul 2011 14:08:24 +0000 (+0000) Subject: Don't allocate the XArray for the text version of the suppression X-Git-Tag: svn/VALGRIND_3_7_0~378 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=75dbd1b0afbacd5264bdc8585c29642245cf0a8e;p=thirdparty%2Fvalgrind.git Don't allocate the XArray for the text version of the suppression until after we've checked if the tool will allow the error to be suppressed, or we will leak it if we do the early return. Spotted by IBM's BEAM checker. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11859 --- diff --git a/coregrind/m_errormgr.c b/coregrind/m_errormgr.c index 98e9d53a6f..57a323f166 100644 --- a/coregrind/m_errormgr.c +++ b/coregrind/m_errormgr.c @@ -346,14 +346,6 @@ static void gen_suppression(Error* err) vg_assert(err); - /* In XML mode, we also need to print the plain text version of the - suppresion in a CDATA section. What that really means is, we - need to generate the plaintext version both in XML and text - mode. So generate it into TEXT. */ - text = VG_(newXA)( VG_(malloc), "errormgr.gen_suppression.1", - VG_(free), sizeof(HChar) ); - vg_assert(text); - ec = VG_(get_error_where)(err); vg_assert(ec); @@ -364,6 +356,14 @@ static void gen_suppression(Error* err) return; } + /* In XML mode, we also need to print the plain text version of the + suppresion in a CDATA section. What that really means is, we + need to generate the plaintext version both in XML and text + mode. So generate it into TEXT. */ + text = VG_(newXA)( VG_(malloc), "errormgr.gen_suppression.1", + VG_(free), sizeof(HChar) ); + vg_assert(text); + /* Ok. Generate the plain text version into TEXT. */ VG_(xaprintf)(text, "{\n"); VG_(xaprintf)(text, " <%s>\n", dummy_name);