IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 8, 2007, 5:57:58 PM (19 years ago)
Author:
Paul Price
Message:

Fixing memory leaks caused by clobbering config->format and config->formatName.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/config/pmConfig.c

    r10965 r10993  
    44 *  @author EAM (IfA)
    55 *
    6  *  @version $Revision: 1.70 $ $Name: not supported by cvs2svn $
    7  *  @date $Date: 2007-01-08 22:26:06 $
     6 *  @version $Revision: 1.71 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2007-01-09 03:57:58 $
    88 *
    99 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    783783    PS_ASSERT_PTR_NON_NULL(header, NULL);
    784784
    785 
    786785    psMetadata *format = NULL;          // The winning format
    787786    psString name = NULL;               // Name of the winning format
     
    814813                config->cameraName = psStringCopy(camerasItem->name);
    815814                config->formatName = name;
    816                 config->format = psMemIncrRefCounter(format);
     815                config->format = format;
    817816            } else {
    818817                psErr *error = psErrorLast();
     
    833832        // Now we have the camera, we can read the recipes
    834833        pmConfigReadRecipes(config, PM_RECIPE_SOURCE_CAMERA | PM_RECIPE_SOURCE_CL);
    835         return format;
     834        return psMemIncrRefCounter(format);
    836835    }
    837836
     
    842841        return NULL;
    843842    }
     843
     844    // Free the format and name just in case they've already been allocated
     845    if (config->format || config->formatName) {
     846        if (config->format != format || strcmp(config->formatName, name) != 0) {
     847            psWarning("Default camera format configuration has changed!\n");
     848        }
     849        psFree(config->format);
     850        psFree(config->formatName);
     851    }
    844852    config->formatName = name;
    845     config->format = psMemIncrRefCounter(format);
    846     return format;
     853    config->format = format;
     854    return psMemIncrRefCounter(format);
    847855}
    848856
Note: See TracChangeset for help on using the changeset viewer.