rgeo / rgeo-proj4

Proj4 extension for rgeo.
MIT License
13 stars 14 forks source link

Can Segfault with Invalid Proj String #25

Closed keithdoggett closed 1 year ago

keithdoggett commented 2 years ago

The following will segfault and create a core dump

require 'rgeo/proj4'

proj_str = "+proj=merc +lat_ts=56.5 +ellps=GRS80"

p1 = RGeo::CoordSys::Proj4.create(proj_str)
p2 = RGeo::CoordSys::Proj4.create("EPSG:3857")

x,y = RGeo::CoordSys::Proj4.transform_coords(p1, p2, 1, 2, nil)

p x
p y

The issue is that the proj_str is not a CRS because it is missing "+type=crs". We should check both proj objects to ensure they are valid before executing a transformation.