]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Don't allocate the XArray for the text version of the suppression
authorTom Hughes <tom@compton.nu>
Wed, 6 Jul 2011 14:08:24 +0000 (14:08 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 6 Jul 2011 14:08:24 +0000 (14:08 +0000)
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

coregrind/m_errormgr.c

index 98e9d53a6f128dfb46ea5d09077a7bfc6afa4ff1..57a323f166c62758e066a7f84d2f04c387a9974d 100644 (file)
@@ -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);