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.
Note:
See TracTickets
for help on using tickets.
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 aPOLYGON EMPTY
.For a
POINT EMPTY
there is no structural analogue to create in a shape file. So we are left with two options:POINT EMPTY
as SHP_NULL type (which is also used for actual SQL NULLs)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…