<div dir="ltr"><div>Hi</div><div><br></div><div>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.</div><div><br></div><div>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:</div><div><br></div><div>- copy the data into "GByte *pabyData"</div><div>- call "VSILFILE *fpRaw = VSIFileFromMemBuffer(osTmpFilename.c_str(), pabyData, ... , true)" with the last parameter to true, so VSI is taking care of the memory.</div><div>- call immediately "VSIFCloseL(fpRaw);" (as I said, the thermal image is a PNG, so I ignore the block in between)</div><div>- create a dataset with "auto poRawDS = GDALDataset::Open(osTmpFilename.c_str(), ...)"</div><div>- call "VSIUnlink(osTmpFilename.c_str());" to close the temporary file</div><div>- "return poRawDS;"</div><div><br></div><div>Calling VSIFCloseL is not deleting the data before calling GDALDataset::Open?</div><div>Calling VSIUnlink is not loosing the access to the data in poRawDS, before it can be used?</div><div><br></div><div>Thank you.</div></div>