chiark / gitweb /
fix memory leak for error condition
authorstevenj <stevenj@alum.mit.edu>
Mon, 12 Jul 2010 22:31:17 +0000 (18:31 -0400)
committerstevenj <stevenj@alum.mit.edu>
Mon, 12 Jul 2010 22:31:17 +0000 (18:31 -0400)
darcs-hash:20100712223117-c8de0-1d1a5920fdadab5ae0f7f25154d7b3d823bd6715.gz

test/testopt.cpp

index b1fed82dfd779bc670c187be102e231ab9d2ae66..307fddfc781b1ab96de50b39ccf7f401f3d9cc94 100644 (file)
@@ -209,6 +209,7 @@ static int test_function(int ifunc)
     printf("return code %d from nlopt_minimize\n", ret);
     if (ret < 0 && ret != NLOPT_ROUNDOFF_LIMITED) {
       fprintf(stderr, "testopt: error in nlopt_minimize\n");
+      free(x);
       return 0;
     }
     printf("Found minimum f = %g after %d evaluations.\n",