Opened 17 years ago

Last modified 17 years ago

#849 closed defect (fixed)

Error to open ecw or mrsid file in GDALOpen function

Reported by: xpaytubi@… Owned by: warmerdam
Priority: high Milestone:
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords:



I'm using a gdal cvs checkout from last week, the last ECW sources and MrSID
libraries. I've compiled the gdal and ecw library with /MDd option.

 * When I try to open a ecw or mrsid file, GDALOpen function crashes. 
 * The call is  like : GDALOpen("C:\\RGBImage.ecw", GA_ReadOnly);

 * I found that ECWDataset::Open (..) uses VSIFOpenL, and this function uses
CreateFile to obtain a handle which then is cast to a FILE*. This pointer is
used to read with fread in ReadBoxes, and this operation crashes. I think there
is a problem using the handle obtained from CreateFile for the fread function.
If I change the CreateFile function to an equivalent fopen(), then everything
seems to work correctly.

Thanks a lot.

Change History (3)

comment:1 by xpaytubi@…, 17 years ago

I have also to change the VSIFCloseL function, and use fclose (...) and not
CloseHandle (...).

comment:2 by warmerdam, 17 years ago


Good job debugging!  I think the correct fix is to use VSIFReadL() 
in gdal/gcore/gdaljp2box.cpp and I have committed the corresponding change
in CVS. 

If you have a chance, could you verify that works OK for you?

On Linux the "large file" and "normal file" FILE handles are compatible, 
so it is easy for me to make mistakes and mix them.  Of course, they aren't
compatible on Win32 as you have encountered. 

comment:3 by xpaytubi@…, 17 years ago

Hi Frank,

I updated gdal from cvs yesterday, and I've verified it. Your fix works perfectly. 

Note: See TracTickets for help on using tickets.