Shp2pgsql invalid free when -W UTF-8
|Reported by:||Matt Amos||Owned by:||pramsey|
Shp2pgsql crashes with an invalid free when passed a
-W UTF-8 argument on the command line and the shapefile contains a code page. This is because shp2pgsql assumes that if the
encoding is the string
UTF-8 then the user has not overridden it. If the code page exists in the shapefile, the previous value of
encoding is freed and, if it came from a command line argument, it is not heap-allocated.
The patch in https://github.com/postgis/postgis/pull/111 prevents the crash by
strduping the command line argument, but doesn't address the wider issue of distinguishing a user-provided "UTF-8" from a default-supplied "UTF-8".