Ticket #1104 (new defect)

Opened 7 years ago

Memory Leak in OGRStyleTool::SetParamStr

Reported by: rlcave3rd@… Owned by: warmerdam
Priority: high Milestone:
Component: OGR_SF Version: unspecified
Severity: normal Keywords:
Cc:

Description

I found this memory leak in GDAL 1.3.1, but I was not able to determine where to
apply a patch.  The string buffer created by the call to CPLStrdup in the
following statement does not seem to get freed:

sStyleValue.pszValue = CPLStrdup(pszParamString);

Here is the whole procedure for context:

void OGRStyleTool::SetParamStr(OGRStyleParamId &sStyleParam ,
                               OGRStyleValue &sStyleValue,
                               const char *pszParamString)
{
    Parse();
    StyleModified();
    sStyleValue.bValid = TRUE;
    sStyleValue.eUnit = GetUnit();
    switch (sStyleParam.eType)
    {
      
        // if sStyleParam.bGeoref == TRUE , need to convert to output value;
      case OGRSTypeString:
        sStyleValue.pszValue = CPLStrdup(pszParamString);
        break;
      case OGRSTypeDouble:
        sStyleValue.dfValue = atof(pszParamString);
        break;
      case OGRSTypeInteger:
        sStyleValue.nValue  = atoi(pszParamString);
        break;
      default:
        sStyleValue.bValid = FALSE;
        break;
    }
}
Note: See TracTickets for help on using tickets.