Index: trunk/psModules/src/config/pmConfig.c
===================================================================
--- trunk/psModules/src/config/pmConfig.c	(revision 10965)
+++ trunk/psModules/src/config/pmConfig.c	(revision 10993)
@@ -4,6 +4,6 @@
  *  @author EAM (IfA)
  *
- *  @version $Revision: 1.70 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-01-08 22:26:06 $
+ *  @version $Revision: 1.71 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-01-09 03:57:58 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -783,5 +783,4 @@
     PS_ASSERT_PTR_NON_NULL(header, NULL);
 
-
     psMetadata *format = NULL;          // The winning format
     psString name = NULL;               // Name of the winning format
@@ -814,5 +813,5 @@
                 config->cameraName = psStringCopy(camerasItem->name);
                 config->formatName = name;
-                config->format = psMemIncrRefCounter(format);
+                config->format = format;
             } else {
                 psErr *error = psErrorLast();
@@ -833,5 +832,5 @@
         // Now we have the camera, we can read the recipes
         pmConfigReadRecipes(config, PM_RECIPE_SOURCE_CAMERA | PM_RECIPE_SOURCE_CL);
-        return format;
+        return psMemIncrRefCounter(format);
     }
 
@@ -842,7 +841,16 @@
         return NULL;
     }
+
+    // Free the format and name just in case they've already been allocated
+    if (config->format || config->formatName) {
+        if (config->format != format || strcmp(config->formatName, name) != 0) {
+            psWarning("Default camera format configuration has changed!\n");
+        }
+        psFree(config->format);
+        psFree(config->formatName);
+    }
     config->formatName = name;
-    config->format = psMemIncrRefCounter(format);
-    return format;
+    config->format = format;
+    return psMemIncrRefCounter(format);
 }
 
