Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#2682 closed defect (fixed)

GDALWriteWorldFile : NULL to derive world-file extension from the pszBaseFilename crashes

Reported by: gislab Owned by: Even Rouault
Priority: normal Milestone: 1.6.0
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords:
Cc:

Description

Documentation says (http://www.gdal.org/gdal_8h.html#dae2ed5807e4ec288812b54c6fccda1e), that it is possible to pass NULL to GDALReadWorldFile to derive it from the filename. Seems like this is not the case for GDALWriteWorldFile (no docs) and passing NULL crashes GDAL.

May be adding something like this would help:

if (pszExtension != NULL)

pszTFW = CPLResetExtension( pszBaseFilename, pszExtension );

else

pszTFW = pszBaseFilename;

-Maxim

Change History (4)

comment:1 by Even Rouault, 15 years ago

Component: defaultGDAL_Raster
Milestone: 1.6.0
Owner: changed from warmerdam to Even Rouault
Status: newassigned

comment:2 by Even Rouault, 15 years ago

Resolution: fixed
Status: assignedclosed

In r15744, I've added doc for GDALWriteWorldFile to specify that pszExtension must not be NULL. VALIDATE_POINTER1 also added to check it.

in reply to:  2 comment:3 by gislab, 15 years ago

Replying to rouault:

In r15744, I've added doc for GDALWriteWorldFile to specify that pszExtension must not be NULL.

Thanks for working on that. Why not allow it to be NULL to generate world filename extension based on raster extension?

comment:4 by Even Rouault, 15 years ago

Because there are many possible extensions depending on the use. For the read case we can try different patterns (for example for a PNG raster : wld, pgw, pngw), but for the write case, the user must specify the one that he really wants.

Note: See TracTickets for help on using tickets.