[gdal-dev] reading raster from memory

Javier Jimenez Shaw j1 at jimenezshaw.com
Wed Jan 21 05:13:01 PST 2026


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20260121/036f31df/attachment.htm>


More information about the gdal-dev mailing list