Index: trunk/ippTools/src/addtool.c
===================================================================
--- trunk/ippTools/src/addtool.c	(revision 34265)
+++ trunk/ippTools/src/addtool.c	(revision 35228)
@@ -988,13 +988,14 @@
     if (strcmp (stage,"cam") == 0) {
       query = pxDataGet("addtool_find_processedexp_cam.sql");
-    }
-    if (strcmp (stage,"stack") == 0) {
+    } else if (strcmp (stage,"stack") == 0) {
       query = pxDataGet("addtool_find_processedexp_stack.sql");
-    }
-    if (strcmp (stage,"staticsky") == 0) {
+    } else if (strcmp (stage,"staticsky") == 0) {
       query = pxDataGet("addtool_find_processedexp_staticsky_multi.sql");
-    }
-    if (strcmp (stage,"skycal") == 0) {
+    } else if (strcmp (stage,"skycal") == 0) {
       query = pxDataGet("addtool_find_processedexp_skycal.sql");
+    } else {
+        psFree(where);
+        psError(PXTOOLS_ERR_CONFIG, false, "can't find sql file for stage %s", stage);
+        return false;
     }
 
