Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential heap corruption #153

Open
akater320 opened this issue Aug 22, 2018 · 3 comments
Open

Potential heap corruption #153

akater320 opened this issue Aug 22, 2018 · 3 comments

Comments

@akater320
Copy link
Contributor

GeoRaster::warp_into(...) allocates an OGRSpatialReference object in one library and deletes it in another. This can be a problem when the libraries are dynamically linked.

OGRSpatialReference* srs = new OGRSpatialReference;

OGRSpatialReference::DestroySpatialReference(srs);

@matthewhanson
Copy link
Member

Thanks for reporting this @akater320

I've been using dynamic libraries - have you run into an error being generated in this case? I'll try and set up some tests to see if I can create an error.

@ircwaves
Copy link
Member

The docs say that is equivalent to doing a delete. Interested in if there is a case where it is problematic.

@akater320
Copy link
Contributor Author

akater320 commented Aug 23, 2018

I've only encountered it on Windows. No problems on Ubuntu. But that seems consistent with the GDAL docs.
https://github.com/OSGeo/gdal/blob/0a12dce446d39869b66fb02be091e2f5f28bf054/gdal/ogr/ogrspatialreference.cpp#L216

Edit: I've only encountered it in debug builds. Release builds seem to work fine.

I tried a couple of tweaks that worked in all cases:

  1. Allocate srs on the stack.
  2. OGRSpatialReference* srs = static_cast<OGRSpatialReference*>(OSRNewSpatialReference(nullptr));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants