Quashing memory leak
authorChad Brewbaker <chad@flyingdogsolutions.com>
Wed, 11 Jan 2017 02:51:24 +0000 (20:51 -0600)
committerChad Brewbaker <chad@flyingdogsolutions.com>
Wed, 11 Jan 2017 02:51:24 +0000 (20:51 -0600)
src/base/cvc4_assert.cpp

index 8d5b9e50844c67a7771218e40d5cc2414ad255e1..9d578dc07baed5ea2e4a1aa8380d9836d9f23859 100644 (file)
@@ -38,10 +38,10 @@ void AssertionException::construct(const char* header, const char* extra,
   // then with a larger one if sprintf tells us to.
   int n = 512;
   char* buf;
+  buf = new char[n];
 
   for(;;) {
-    buf = new char[n];
-
     int size;
     if(extra == NULL) {
       size = snprintf(buf, n, "%s\n%s\n%s:%d\n",
@@ -66,6 +66,7 @@ void AssertionException::construct(const char* header, const char* extra,
       // try again with a buffer that's large enough
       n = size + 1;
       delete [] buf;
+      buf = new char[n];
     }
   }