Skip to content

Commit

Permalink
Fix memory leak in CRS.to_authority/CRS.list_authority
Browse files Browse the repository at this point in the history
List elements were not properly disposed of when iterating the results of proj_identify. This fixes this and simplifies the cleanup logic.
  • Loading branch information
skogler committed Nov 12, 2022
1 parent 07bf470 commit 01b793b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/history.rst
Expand Up @@ -8,6 +8,7 @@ Latest
-----
- BUG: Changed so that the setup.cfg depends on the version code in the __init__.py instead of the other way around (issuue #1155)
- BUG: Fix :meth:`.CRS.to_cf` for Pole rotation GRIB convention (pull #1167)
- BUG: Fix :meth:`.CRS.to_authority` memory leak (pull #1178)
- REF: Use upper case EPSG code when creating CRS (pull #1162)

3.4.0
Expand Down
8 changes: 6 additions & 2 deletions pyproj/_crs.pyx
Expand Up @@ -2883,9 +2883,13 @@ cdef class _CRS(Base):
out_confidence_list[iii]
)
)
# at this point, the auth name is copied and we can release the proj object
proj_destroy(proj)
proj = NULL
finally:
for iii in range(num_proj_objects):
proj_destroy(proj_list_get(self.context, proj_list, iii))
# If there was an error we have to call proj_destroy
# If there was none, calling it on NULL does nothing
proj_destroy(proj)
proj_list_destroy(proj_list)
CRSError.clear()
return authority_list
Expand Down

0 comments on commit 01b793b

Please sign in to comment.