Changeset 1585:5ffcd83c54fd


Ignore:
Timestamp:
02/20/10 11:20:39 (5 months ago)
Author:
Howard Butler <hobu.inc@…>
Branch:
default
Message:

apply Even's patch for #154

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/lasspatialreference.cpp

    r1578 r1585  
    392392            && strstr(pszWKT,"COMPD_CS") != NULL ) 
    393393        { 
    394             OGRSpatialReference* poSRS = new OGRSpatialReference(); 
     394            OGRSpatialReference* poSRS = (OGRSpatialReference*) OSRNewSpatialReference(NULL); 
    395395            char *pszOrigWKT = pszWKT; 
    396396            poSRS->importFromWkt( &pszOrigWKT ); 
     
    401401            poSRS->StripVertical(); 
    402402            poSRS->exportToWkt( &pszWKT ); 
     403             
     404            OGRSpatialReference::DestroySpatialReference(poSRS); 
    403405        } 
    404406#endif 
     
    407409        { 
    408410            std::string tmp(pszWKT); 
    409             std::free(pszWKT); 
     411            CPLFree(pszWKT); 
    410412            return tmp; 
    411413        } 
     
    421423    char* poWKT = 0; 
    422424    const char* input = v.c_str(); 
    423     OGRSpatialReference* poSRS = new OGRSpatialReference(); 
     425    OGRSpatialReference* poSRS = (OGRSpatialReference*) OSRNewSpatialReference(NULL); 
    424426    if (OGRERR_NONE != poSRS->SetFromUserInput((char *) input)) 
    425427    { 
    426         delete poSRS; 
     428        OGRSpatialReference::DestroySpatialReference(poSRS); 
    427429        throw std::invalid_argument("could not import coordinate system into OSRSpatialReference SetFromUserInput"); 
    428430    } 
    429431     
    430432    poSRS->exportToWkt(&poWKT); 
    431     delete poSRS; 
     433    OGRSpatialReference::DestroySpatialReference(poSRS); 
    432434     
    433435    std::string tmp(poWKT); 
    434     std::free(poWKT); 
     436    CPLFree(poWKT); 
    435437     
    436438    SetWKT(tmp); 
     
    516518    const char* poWKT = wkt.c_str(); 
    517519     
    518     OGRSpatialReference* poSRS = new OGRSpatialReference(); 
     520    OGRSpatialReference* poSRS = (OGRSpatialReference*) OSRNewSpatialReference(NULL); 
    519521    if (OGRERR_NONE != poSRS->importFromWkt((char **) &poWKT)) 
    520522    { 
    521         delete poSRS; 
     523        OGRSpatialReference::DestroySpatialReference(poSRS); 
    522524        return std::string(); 
    523525    } 
     
    526528    poSRS->exportToProj4(&proj4); 
    527529    std::string tmp(proj4); 
    528     std::free(proj4); 
    529      
    530     delete poSRS; 
     530    CPLFree(proj4); 
     531     
     532    OGRSpatialReference::DestroySpatialReference(poSRS); 
    531533 
    532534    return tmp; 
     
    543545        char* proj4def = GTIFGetProj4Defn(&defn); 
    544546        std::string tmp(proj4def); 
    545         std::free(proj4def); 
     547        std::free(proj4def); /* risk of cross-heap issue, but no free function in libgeotiff matching GTIFGetProj4Defn */ 
    546548 
    547549        return tmp; 
     
    565567    char* poWKT = 0; 
    566568    const char* poProj4 = v.c_str(); 
    567     OGRSpatialReference* poSRS = new OGRSpatialReference(); 
     569    OGRSpatialReference* poSRS = (OGRSpatialReference*) OSRNewSpatialReference(NULL); 
    568570    if (OGRERR_NONE != poSRS->importFromProj4((char *) poProj4)) 
    569571    { 
    570         delete poSRS; 
     572        OGRSpatialReference::DestroySpatialReference(poSRS); 
    571573        throw std::invalid_argument("could not import proj4 into OSRSpatialReference SetProj4"); 
    572574    } 
    573575     
    574576    poSRS->exportToWkt(&poWKT); 
    575     delete poSRS; 
     577    OGRSpatialReference::DestroySpatialReference(poSRS); 
    576578     
    577579    std::string tmp(poWKT); 
    578     std::free(poWKT); 
     580    CPLFree(poWKT); 
    579581         
    580582    int ret = 0; 
     
    597599        char* proj4def = GTIFGetProj4Defn(&defn); 
    598600        std::string tmp(proj4def); 
    599         std::free(proj4def); 
     601        std::free(proj4def); /* risk of cross-heap issue, but no free function in libgeotiff matching GTIFGetProj4Defn */ 
    600602    } 
    601603#else 
Note: See TracChangeset for help on using the changeset viewer.