Opened 5 years ago

Closed 5 years ago

#4437 closed defect (fixed)

pgsql2shp makes dangerous call to liblwgeom on POINT EMPTY

Reported by: strk Owned by: robe
Priority: critical Milestone: PostGIS 2.5.3
Component: utils/loader-dumper Version: master
Keywords: Cc:

Description

It looks like dumping empty points is doing bad things from dumper:

$ pgsql2shp pg25 "select 'POINT EMPTY'::geometry"
Initializing... 
Done (postgis major version: 3).
Output shape: Point
Dumping: Xlwgeom_api.c [135] called with n=0 and npoints=0

I tested this in current trunk (r17559) but I suspect it happens in older versions too. BTW, that message was once an ERROR or fatal assertion, and only "recently" (?) turned into a notice instead.

Change History (5)

comment:1 by pramsey, 5 years ago

This is interesting… there is no explicit handling of empty in the dumper.

If you ask for a LINESTRING EMPTY it will create for you a line string with zero vertices in the shape file. Similarly for a POLYGON EMPTY.

For a POINT EMPTY there is no structural analogue to create in a shape file. So we are left with two options:

  • Treat POINT EMPTY as SHP_NULL type (which is also used for actual SQL NULLs)
  • Treat _all_ empties as SHP_NULL type
  • Treat POINT EMPTY as a special case as in WKB, filling in the coordinates with NAN (hmm).

The second case changes existing behaviour the least, so I'm inclined to it. The third has a certain symmetry with WKB, but then we also need the inverse behaviour to convert POINT(NAN NAN) in a shape file into an empty…

comment:2 by pramsey, 5 years ago

In 17650:

Handle POINT EMPTY in shape loader/dumper
References #4437

comment:3 by pramsey, 5 years ago

In 17651:

Handle POINT EMPTY in shape loader/dumper
References #4437

comment:4 by pramsey, 5 years ago

In 17652:

Handle POINT EMPTY in shape loader/dumper
References #4437

comment:5 by pramsey, 5 years ago

Resolution: fixed
Status: newclosed

In 17653:

Handle POINT EMPTY in shape loader/dumper
Closes #4437

Note: See TracTickets for help on using tickets.