[gdal-dev] GDALDatasetDriver->poDriver = NULL
Even Rouault
even.rouault at spatialys.com
Thu Oct 8 08:38:03 PDT 2020
On jeudi 8 octobre 2020 17:17:29 CEST Momtchil Momtchev wrote:
> Hello,
>
>
> Is it normal that for this code
>
> int main() {
> GDALAllRegister();
> const char *pszFormat = "GTiff";
> GDALDriver *driver =
> GetGDALDriverManager()->GetDriverByName(pszFormat); if (driver == nullptr)
> {
> printf("driver is null\n");
> return 1;
> }
> std::string path = "sample.tif";
> GDALAccess access = GA_ReadOnly;
> GDALOpenInfo *open_info = new GDALOpenInfo(path.c_str(), access);
> GDALDataset *ds = driver->pfnOpen(open_info);
> printf("%p\n", ds->GetDriver());
> printf("%s\n", ds->GetDriver()->GetDescription());
> }
>
> I get ds->GetDriver = NULL (and a segfault on the following line)? Tried
> on 3.1.2 and 3.1.0
Yes, you're using an implementation detail when using pfnOpen, that is not supposed to be
used by user code. You should rather use GDALOpen / GDALOpenEx / GDALDataset::Open
instead of using directly driver->pfnOpen
Those functions are the ones that set the poDriver member of the GDALDataset
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20201008/b822389c/attachment.html>
More information about the gdal-dev
mailing list