diff src/cjr_print.sml @ 425:7009b0ac1501

Properly freeing libpq results on errors
author Adam Chlipala <adamc@hcoop.net>
date Fri, 24 Oct 2008 17:30:07 -0400
parents b10132434adc
children 5de838fb0950
line wrap: on
line diff
--- a/src/cjr_print.sml	Fri Oct 24 16:47:18 2008 -0400
+++ b/src/cjr_print.sml	Fri Oct 24 17:30:07 2008 -0400
@@ -850,6 +850,8 @@
 
                  string "uw_end_region(ctx);",
                  newline,
+                 string "uw_push_cleanup(ctx, (void (*)(void *))PQclear, res);",
+                 newline,
                  string "n = PQntuples(res);",
                  newline,
                  string "for (i = 0; i < n; ++i) {",
@@ -906,7 +908,7 @@
                  string "}",
                  newline,
                  newline,
-                 string "PQclear(res);",
+                 string "uw_pop_cleanup(ctx);",
                  newline,
                  if wontLeakAnything then
                      box [string "uw_end_region(ctx);",