Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#7212 closed defect (fixed)

EXIF Tag Writing: Fails to write variable-length tags of integer/real type

Reported by: molnar Owned by: warmerdam
Priority: normal Milestone:
Component: GDAL_Raster Version: svn-trunk
Severity: normal Keywords:
Cc:

Description

The loop condition is probably not what you were going for; see here at line 1124 in gcore/gdalexif.cpp:

tag.nLength = (tagdescArray[i].length == 0) ? nTokens :
    tagdescArray[i].length;
tag.pabyVal = reinterpret_cast<GByte*>(
    CPLCalloc(1, nDataTypeSize * tag.nLength));

GUInt32 nOffset = 0;
for( GUInt32 j = 0; j < std::min(nTokens,
    tagdescArray[i].length); j++ )

Variable-length tags have tagdescArray[i].length of 0, which is properly accounted-for in the first block. However, we are later calling std::min() with that same value, so it will always return 0 in that case.

Hence, we will never write any values for variable-length tags of this type.

The problem is the same for both the TIFF_SHORT/TIFF_LONG case and the TIFF_RATIONAL/TIFF_SRATIONAL case.

I believe the problem will be addressed if you replace the second argument to std::min() with tag.nLength, or some equivalent fix.

Change History (2)

comment:1 by Even Rouault, 5 years ago

Resolution: fixed
Status: newclosed

In 41334:

EXIF writer: fix writing of variable length tags of integer/real type (patch by molnar, fixes #7212)

comment:2 by molnar, 5 years ago

I've got to hand it to you: you sure are fast with these responses! Much appreciated.

Note: See TracTickets for help on using tickets.