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

Add checks for unititialized pyproj.crs objects to prevent core dumping #434

Merged
merged 2 commits into from
Sep 11, 2019

Conversation

snowman2
Copy link
Member

@snowman2 snowman2 commented Sep 11, 2019

@snowman2 snowman2 merged commit aab1acb into pyproj4:master Sep 11, 2019
@snowman2 snowman2 deleted the crs_init_check branch September 11, 2019 12:43
@@ -295,6 +295,10 @@ cdef class Base:
if self.context != NULL:
proj_context_destroy(self.context)

def _ensure_initialized(self):
if self.projobj == NULL:
raise CRSError("Object not initialized.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively to doing those checks in all methods, can't we simply disallow creating an uninitialized object?

So that it already raises an error if you do d = Datum() ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to have that ability in the create methods:

cdef CoordinateSystem coord_system = CoordinateSystem()

So, this is the next best thing I could think of.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking for initialization in cython, I found in their docs:

... use a factory function instead that handles the object initialisation. It often helps to directly call __new__() in this function to bypass the call to the __init__() constructor.

https://cython.readthedocs.io/en/latest/src/userguide/special_methods.html

So that would also be an option I think

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking for initialization in cython, I found in their docs:

... use a factory function instead that handles the object initialisation. It often helps to directly call __new__() in this function to bypass the call to the __init__() constructor.

https://cython.readthedocs.io/en/latest/src/userguide/special_methods.html

So that would also be an option I think

That sounds like a much more secure/simple method for this. I will give it a go later.

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

Successfully merging this pull request may close these issues.

pyproj.crs.PrimeMeridian() core dumps on Ubuntu
2 participants