Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#5245 closed defect (fixed)

bug in gdal_translate when checking that color table only contains gray levels

Reported by: BoisvertEric Owned by: warmerdam
Priority: normal Milestone: 1.10.2
Component: default Version: unspecified
Severity: minor Keywords: ColorTable
Cc:

Description

in gdal_translate.cpp

/* Check that the color table only contains gray levels */
1260	        /* when using -expand gray */
1261	        if (nRGBExpand == 1)
1262	        {
1263	            int nColorCount = poColorTable->GetColorEntryCount();
1264	            int nColor;
1265	            for( nColor = 0; nColor < nColorCount; nColor++ )
1266	            {
1267	                const GDALColorEntry* poEntry = poColorTable->GetColorEntry(nColor);
1268	                if (poEntry->c1 != poEntry->c2 || poEntry->c1 != poEntry->c2)
1269	                {
1270	                    fprintf(stderr, "Warning : color table contains non gray levels colors\n");
1271	                    break;
1272	                }
1273	            }
1274	        }

I suspect line 1268 should read

if (poEntry->c1 != poEntry->c2 || poEntry->c1 != poEntry->c3)

(or I totally missed the logic)

Change History (2)

comment:1 by Even Rouault, 11 years ago

Milestone: 1.10.2
Resolution: fixed
Status: newclosed

Good catch. Thanks. Fixed in trunk (r26475) and branches/1.10 (r26476)

comment:2 by Kyle Shannon, 11 years ago

Fixes Coverity #1074940 as well.

Note: See TracTickets for help on using tickets.