Index: trunk/ppImage/src/ppImage.c
===================================================================
--- trunk/ppImage/src/ppImage.c	(revision 13843)
+++ trunk/ppImage/src/ppImage.c	(revision 13901)
@@ -18,4 +18,5 @@
     if (config == NULL) {
         psErrorStackPrint(stderr, "Unable to parse command-line arguments.");
+        ppImageCleanup(config, NULL);
         exit(PS_EXIT_CONFIG_ERROR);
     }
@@ -26,4 +27,5 @@
     if (options == NULL) {
         psErrorStackPrint(stderr, "Unable to parse camera.");
+        ppImageCleanup(config, options);
         exit(PS_EXIT_CONFIG_ERROR);
     }
@@ -32,4 +34,5 @@
     if (!ppImageLoop(config, options)) {
         psErrorStackPrint(stderr, "Unable to loop over input");
+        ppImageCleanup(config, options);
         exit(PS_EXIT_SYS_ERROR);
     }
@@ -62,6 +65,6 @@
             if (fpa->hdu->header) fprintf (stderr, "  (%d,%d) header\n", -1, -1);
         } else {
-	    // fprintf (stderr, "  has no fpa data (%d,%d)\n", -1, -1);
-	}
+            // fprintf (stderr, "  has no fpa data (%d,%d)\n", -1, -1);
+        }
         for (int i = 0; i < fpa->chips->n; i++) {
             pmChip *chip = fpa->chips->data[i];
@@ -72,6 +75,6 @@
                 if (chip->hdu->header) fprintf (stderr, "  (%d,%d) header\n", i, -1);
             } else {
-		// fprintf (stderr, "  has no chip data (%d,%d)\n", i, -1);
-	    }
+                // fprintf (stderr, "  has no chip data (%d,%d)\n", i, -1);
+            }
             for (int j = 0; j < chip->cells->n; j++) {
                 pmCell *cell = chip->cells->data[j];
@@ -82,14 +85,14 @@
                     if (cell->hdu->header) fprintf (stderr, "  (%d,%d) header\n", i, j);
                 } else {
-		    // fprintf (stderr, "  has no cell data (%d,%d)\n", i, j);
-		}
-		for (int k = 0; k < cell->readouts->n; k++) {
-		    pmReadout *readout = cell->readouts->data[k];
-		    if (readout) {
-			if (readout->image) fprintf (stderr, "  (%d,%d,%d) image\n", i, j, k);
-			if (readout->weight) fprintf (stderr, "  (%d,%d,%d) weight\n", i, j, k);
-			if (readout->mask) fprintf (stderr, "  (%d,%d,%d) masks\n", i, j, k);
-		    }
-		}
+                    // fprintf (stderr, "  has no cell data (%d,%d)\n", i, j);
+                }
+                for (int k = 0; k < cell->readouts->n; k++) {
+                    pmReadout *readout = cell->readouts->data[k];
+                    if (readout) {
+                        if (readout->image) fprintf (stderr, "  (%d,%d,%d) image\n", i, j, k);
+                        if (readout->weight) fprintf (stderr, "  (%d,%d,%d) weight\n", i, j, k);
+                        if (readout->mask) fprintf (stderr, "  (%d,%d,%d) masks\n", i, j, k);
+                    }
+                }
             }
         }
