Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#4816 closed defect (fixed)

ds.SetMetadata('non_key_equal_value_content', 'GEOLOCATION') crashes on GeoTIFF

Reported by: Even Rouault Owned by: Even Rouault
Priority: normal Milestone: 1.9.2
Component: default Version: unspecified
Severity: normal Keywords:


The following snippet crashes :

    import osgeo.gdal as gdal
    from osgeo.gdalconst import *
    d=gdal.Open('', GA_Update)
    d.SetMetadata('PIXEL_SKIP=1', 'GEOLOCATION')

This is due to 'PIXEL_SKIP=1' being passed as a string, and not as an array.

There are 2 problems in fact :

1) The SWIG bindings have an alternate definition of SetMetadata() that should allow specifying a metadata string instead of a metadata array, but that doesn't work due to method wrongly interpreting the string as an array of characters, which is not wanted

2) The GeoTIFF driver isn't robust to metadata strings not being under the k=v format

Change History (2)

comment:1 by Even Rouault, 10 years ago

Milestone: 1.9.2
Resolution: fixed
Status: newclosed

trunk r24935 : swig/include/python/ swig/python/extensions/ frmts/gtiff/geotiff.cpp -m "GTiff and Python bindings: better handling of SetMetadata(a_string) (#4816)"

branches/1.9 r24936 : frmts/gtiff/geotiff.cpp -m "GTiff: avoid crash on metadata that isn't formatted like key=value (#4816)"

(The 1.9 commit doesn't include the improvement/fix in Python bindings, just the fix for the crash)

comment:2 by Even Rouault, 10 years ago

trunk r24953: Test SetMetadata() fixes in the GTiff driver (#4816)

Note: See TracTickets for help on using tickets.