Hi I am preparing a PR to read the Embedded image from a FLIR jpeg file (another image inside the FLIR, yes). I am confused about how to implement one step, avoiding leaks or invalid memory access.
Taking the funcion JPGDatasetCommon::OpenRawThermalImage (gdal/frmts/jpeg/jpgdataset.cpp) as a reference (when the thermal image is PNG), if I understand correctly, the steps are: - copy the data into "GByte *pabyData" - call "VSILFILE *fpRaw = VSIFileFromMemBuffer(osTmpFilename.c_str(), pabyData, ... , true)" with the last parameter to true, so VSI is taking care of the memory. - call immediately "VSIFCloseL(fpRaw);" (as I said, the thermal image is a PNG, so I ignore the block in between) - create a dataset with "auto poRawDS = GDALDataset::Open(osTmpFilename.c_str(), ...)" - call "VSIUnlink(osTmpFilename.c_str());" to close the temporary file - "return poRawDS;" Calling VSIFCloseL is not deleting the data before calling GDALDataset::Open? Calling VSIUnlink is not loosing the access to the data in poRawDS, before it can be used? Thank you.
_______________________________________________ gdal-dev mailing list [email protected] https://lists.osgeo.org/mailman/listinfo/gdal-dev
