Index: trunk/psModules/src/camera/pmFPAfileDefine.c
===================================================================
--- trunk/psModules/src/camera/pmFPAfileDefine.c	(revision 11876)
+++ trunk/psModules/src/camera/pmFPAfileDefine.c	(revision 12152)
@@ -163,4 +163,5 @@
     if (file->type == PM_FPA_FILE_NONE) {
         psError(PS_ERR_IO, true, "FILE.TYPE is not defined for %s\n", name);
+        psFree(file);
         return NULL;
     }
@@ -176,4 +177,5 @@
         } else {
             psError(PS_ERR_IO, true, "Illegal value \"%s\" for FILE.SAVE for %s", save, name);
+            psFree(file);
             return NULL;
         }
@@ -190,5 +192,6 @@
     // select the format list from the selected camera
     const char *formatName = psMetadataLookupStr (&status, data, "FILE.FORMAT");
-    if (!formatName) {
+    if (!formatName || strcmp(formatName, "NONE") == 0) {
+        // Try to get by with the default
         formatName = config->formatName;
     }
@@ -196,6 +199,8 @@
     psMetadata *format = psMetadataLookupMetadata(&status, formats, formatName); // Camera format to use
     if (!format) {
-        // Try to get by with the default
-        format = config->format;
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find format %s for file %s.\n",
+                formatName, file->name);
+        psFree(file);
+        return NULL;
     }
     file->format = psMemIncrRefCounter(format);
@@ -206,4 +211,5 @@
     if (file->fileLevel == PM_FPA_LEVEL_NONE) {
         psError(PS_ERR_IO, true, "Unable to determine file level for %s\n", name);
+        psFree(file);
         return NULL;
     }
@@ -212,4 +218,5 @@
     if (file->dataLevel == PM_FPA_LEVEL_NONE) {
         psError(PS_ERR_IO, true, "DATA.LEVEL is not set for %s\n", name);
+        psFree(file);
         return NULL;
     }
@@ -820,9 +827,9 @@
         char *concept = item->data.V;
 
-	// these items refer to the corresponding values for the input image 
-	// (ie, -filter input:filter or -exptime input:exptime)
+        // these items refer to the corresponding values for the input image
+        // (ie, -filter input:filter or -exptime input:exptime)
         if (!strcasecmp (option, "filter")) {
             options->filter = psMetadataLookupPtr (&status, input->concepts, concept);
-	    psMemIncrRefCounter (options->filter);
+            psMemIncrRefCounter (options->filter);
             if (!status)
                 psAbort("failed to find filter (concept %s)", concept);
@@ -831,5 +838,5 @@
         if (!strcasecmp (option, "exptime")) {
             options->exptime = psMetadataLookupF32 (&status, input->concepts, concept);
-	    options->exptimeSet = true;
+            options->exptimeSet = true;
             if (!status)
                 psAbort("exptime not found (concept %s)", concept);
@@ -837,28 +844,28 @@
         if (!strcasecmp (option, "airmass")) {
             options->airmass = psMetadataLookupF32 (&status, input->concepts, concept);
-	    options->airmassSet = true;
+            options->airmassSet = true;
             if (!status)
                 psAbort("airmass not found (concept %s)", concept);
         }
-	if (!strcasecmp (option, "dettemp")) {
-	    options->dettemp = psMetadataLookupF32 (&status, input->concepts, concept);
-	    options->dettempSet = true;
-	    if (!status)
-		psAbort("dettemp not found (concept %s)", concept);
-	}
+        if (!strcasecmp (option, "dettemp")) {
+            options->dettemp = psMetadataLookupF32 (&status, input->concepts, concept);
+            options->dettempSet = true;
+            if (!status)
+                psAbort("dettemp not found (concept %s)", concept);
+        }
         if (!strcasecmp (option, "twilight")) {
             options->twilight = psMetadataLookupF32 (&status, input->concepts, concept);
-	    options->twilightSet = true;
+            options->twilightSet = true;
             if (!status)
                 psAbort("twilight not found (concept %s)", concept);
         }
 
-	// the version is applied literally
+        // the version is applied literally
         if (!strcasecmp (option, "version")) {
             options->version = psMemIncrRefCounter (concept);
         }
-	// we can override the detrend database dettype if desired
-	// ie, use DOMEFLAT for type FLAT
-	// the dettype string is applied literally
+        // we can override the detrend database dettype if desired
+        // ie, use DOMEFLAT for type FLAT
+        // the dettype string is applied literally
         if (!strcasecmp (option, "dettype")) {
             options->dettype = psMemIncrRefCounter (concept);
