Skip to content

Commit

Permalink
Fix leak in set_proj_search_path
Browse files Browse the repository at this point in the history
The `CSLAddString` function takes a `char *`, not a `const char *`,
which may turn into an error on new GCC. It also allocates a new array
when given `NULL`, which is _copied_ by `OSRSetPROJSearchPaths`, so it
is leaked.
  • Loading branch information
QuLogic committed Dec 2, 2023
1 parent 1df00ee commit b6d6d9d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fiona/_env.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ except ImportError:
cdef bint is_64bit = sys.maxsize > 2 ** 32

cdef void set_proj_search_path(object path):
cdef const char **paths = NULL
cdef char **paths = NULL
cdef const char *path_c = NULL
path_b = path.encode("utf-8")
path_c = path_b
paths = CSLAddString(paths, path_c)
OSRSetPROJSearchPaths(paths)
OSRSetPROJSearchPaths(<const char *const *>paths)
CSLDestroy(paths)


cdef _safe_osr_release(OGRSpatialReferenceH srs):
Expand Down

0 comments on commit b6d6d9d

Please sign in to comment.