Index: trunk/ippTools/src/pxinject.c
===================================================================
--- trunk/ippTools/src/pxinject.c	(revision 11853)
+++ trunk/ippTools/src/pxinject.c	(revision 11854)
@@ -44,4 +44,8 @@
 
     pxConfig *config = pxinjectConfig(NULL, argc, argv);
+    if (!config) {
+        psError(PXTOOLS_ERR_CONFIG, false, "failed to configure");
+        goto FAIL;
+    }
 
     switch (config->mode) {
@@ -60,4 +64,5 @@
 FAIL:
     psErrorStackPrint (stderr, "failure\n");
+    int exit_status = pxerrorGetExitStatus();
 
     psFree(config);
@@ -65,5 +70,5 @@
     psLibFinalize();
 
-    exit(EXIT_FAILURE);
+    exit(exit_status);
 }
 
Index: trunk/ippTools/src/pxinjectConfig.c
===================================================================
--- trunk/ippTools/src/pxinjectConfig.c	(revision 11853)
+++ trunk/ippTools/src/pxinjectConfig.c	(revision 11854)
@@ -27,6 +27,6 @@
 #include "pxinject.h"
 
-// this function can not fail -- exits on error
-pxConfig *pxinjectConfig(pxConfig *config, int argc, char **argv) {
+pxConfig *pxinjectConfig(pxConfig *config, int argc, char **argv)
+{
     if (!config) {
         config = pxConfigAlloc();
@@ -39,5 +39,6 @@
     if (!config->modules) {
         psError(PS_ERR_UNKNOWN, false, "Can't find site configuration");
-        goto FAIL;
+        psFree(config);
+        return NULL;
     }
 
@@ -105,5 +106,6 @@
         psFree(newImfileArgs);
 
-        goto FAIL;
+        psFree(config);
+        return NULL;
     }
 
@@ -119,5 +121,6 @@
         if (!psMetadataAddStr(config->where, PS_LIST_TAIL, #name, 0, "==", str)) {\
             psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
-            goto FAIL; \
+            psFree(config); \
+            return NULL; \
         } \
     } \
@@ -134,5 +137,6 @@
             if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "iteration", 0, "==", n)) {
                 psError(PS_ERR_UNKNOWN, false, "failed to add item iteration");
-                goto FAIL;
+                psFree(config);
+                return NULL;
             }
         }
@@ -148,5 +152,6 @@
             if (!psMetadataAddStr(config->where, PS_LIST_TAIL, "camera", 0, "==", str)) {
                 psError(PS_ERR_UNKNOWN, false, "failed to add item camera");
-                goto FAIL;
+                psFree(config);
+                return NULL;
             }
         }
@@ -159,5 +164,6 @@
             if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "imfiles", 0, "==", n)) {
                 psError(PS_ERR_UNKNOWN, false, "failed to add item imfiles");
-                goto FAIL;
+                psFree(config);
+                return NULL;
             }
         }
@@ -172,5 +178,6 @@
             if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "p1_version", 0, "==", n)) {
                 psError(PS_ERR_UNKNOWN, false, "failed to add item p1_version");
-                goto FAIL;
+                psFree(config);
+                return NULL;
             }
         }
@@ -183,5 +190,6 @@
             if (!psMetadataAddBool(config->where, PS_LIST_TAIL, "accept", 0, "==", boolean)) {
                 psError(PS_ERR_UNKNOWN, false, "failed to add item accept");
-                goto FAIL;
+                psFree(config);
+                return NULL;
             }
         }
@@ -199,5 +207,6 @@
     if (!config->dbh) {
         psError(PS_ERR_UNKNOWN, false, "Can't configure database");
-        goto FAIL;
+        psFree(config);
+        return NULL;
     }
 
@@ -207,9 +216,3 @@
 
     return config;
-
-FAIL:
-    psFree(config);
-    pmConfigDone();
-    psLibFinalize();
-    exit(EXIT_FAILURE);
 }
