[PostGIS] #5994: null pointer dereference in ST_AsGeoJsonRow

PostGIS trac at osgeo.org
Tue Sep 30 10:11:08 PDT 2025


#5994: null pointer dereference in ST_AsGeoJsonRow
---------------------+---------------------------
 Reporter:  pramsey  |      Owner:  pramsey
     Type:  defect   |     Status:  new
 Priority:  medium   |  Milestone:  PostGIS 3.5.4
Component:  postgis  |    Version:  3.5.x
 Keywords:           |
---------------------+---------------------------
 If extension is created before 3.5 and the actual postgis-3.so is from
 3.5 and newer, we experience crash when ST_AsGeoJsonRow() is called.

 Crash happens because of ST_AsGeoJsonRow() expects to get id_column
 value as an empty string, however this parameter doesn't exist in old
 version of the function:
 {{{
 -- Availability: 3.0.0
 -- Changed: 3.5.0 add id_column='' parameter
 -- Replaces ST_AsGeoJson(record, text, integer, bool) deprecated in 3.5.0
 CREATE OR REPLACE FUNCTION ST_AsGeoJson(r record, geom_column text DEFAULT
 '', maxdecimaldigits integer DEFAULT 9, pretty_bool boolean DEFAULT false,
 id_column text DEFAULT '')
     RETURNS text
     AS 'MODULE_PATHNAME','ST_AsGeoJsonRow'
     LANGUAGE 'c' STABLE STRICT PARALLEL SAFE
     _COST_MEDIUM;
 }}}
 As a result, we receive NULL and text_to_cstring(NULL) call results in
 segfault.

 https://github.com/postgis/postgis/pull/833
-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5994>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list