[SCM] PostGIS branch stable-3.3 updated. 3.3.7-36-ga0efda650
git at osgeo.org
git at osgeo.org
Thu Jun 5 14:12:15 PDT 2025
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".
The branch, stable-3.3 has been updated
via a0efda650bb87c749e77f50109052e27797c4710 (commit)
from 5bc962a13791784151a99242e12060fbe96773a0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit a0efda650bb87c749e77f50109052e27797c4710
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Thu Jun 5 14:12:10 2025 -0700
Remove crash when using xlink without a gml prefix, references #5912
diff --git a/NEWS b/NEWS
index 5a393e02f..b09cc72fc 100644
--- a/NEWS
+++ b/NEWS
@@ -13,7 +13,8 @@ Proj 4.9+ required.
- #5829, geometry_columns with non-standard constraints (Paul Ramsey)
- #5818, GT-244 Fix CG_IsSolid function (Loïc Bartoletti)
- #5885, Fix documentation about grid-based overlay operations (Sandro Santilli)
- - #5921, Crash freeing uninitialized pointer (Arsenii Mukhin)
+ - #5921, Crash freeing uninitialized pointer (Arsenii Mukhin)
+ - #5912, Crash on GML with xlink and no prefix (Paul Ramsey)
PostGIS 3.3.8
diff --git a/postgis/lwgeom_in_gml.c b/postgis/lwgeom_in_gml.c
index 0d7036511..7ce6c76d2 100644
--- a/postgis/lwgeom_in_gml.c
+++ b/postgis/lwgeom_in_gml.c
@@ -265,16 +265,29 @@ static xmlNodePtr get_xlink_node(xmlNodePtr xnode)
xmlChar *href, *p, *node_id;
href = xmlGetNsProp(xnode, (xmlChar *)"href", (xmlChar *) XLINK_NS);
- id = lwalloc((xmlStrlen(xnode->ns->prefix) * 2 + xmlStrlen(xnode->name)
- + xmlStrlen(href) + sizeof("//:[@:id='']") + 1));
p = href;
p++; /* ignore '#' first char */
- /* XPath pattern look like: //gml:point[@gml:id='p1'] */
- sprintf(id, "//%s:%s[@%s:id='%s']", (char *) xnode->ns->prefix,
- (char *) xnode->name,
- (char *) xnode->ns->prefix,
- (char *) p);
+ if (xnode->ns)
+ {
+ id = lwalloc((xmlStrlen(xnode->ns->prefix) * 2 + xmlStrlen(xnode->name) +
+ xmlStrlen(href) + sizeof("//:[@:id='']") + 1));
+ /* XPath pattern look like: //gml:point[@gml:id='p1'] */
+ sprintf(id, "//%s:%s[@%s:id='%s']",
+ (char *) xnode->ns->prefix,
+ (char *) xnode->name,
+ (char *) xnode->ns->prefix,
+ (char *) p);
+ }
+ else
+ {
+ id = lwalloc((xmlStrlen(xnode->name) +
+ xmlStrlen(href) + sizeof("//:[@:id='']") + 1));
+ /* XPath pattern look like: //gml:point[@gml:id='p1'] */
+ sprintf(id, "//%s[@id='%s']",
+ (char *) xnode->name,
+ (char *) p);
+ }
ctx = xmlXPathNewContext(xnode->doc);
if (ctx == NULL)
@@ -1047,6 +1060,8 @@ static LWGEOM* parse_gml_point(xmlNodePtr xnode, bool *hasz, int *root_srid)
POINTARRAY *pa;
if (is_xlink(xnode)) xnode = get_xlink_node(xnode);
+ if (xnode == NULL)
+ gml_lwpgerror("invalid GML representation", 30);
if (xnode->children == NULL)
return lwpoint_as_lwgeom(lwpoint_construct_empty(*root_srid, 0, 0));
@@ -1082,6 +1097,8 @@ static LWGEOM* parse_gml_line(xmlNodePtr xnode, bool *hasz, int *root_srid)
POINTARRAY *pa;
if (is_xlink(xnode)) xnode = get_xlink_node(xnode);
+ if (xnode == NULL)
+ gml_lwpgerror("invalid GML representation", 30);
if (xnode->children == NULL)
return lwline_as_lwgeom(lwline_construct_empty(*root_srid, 0, 0));
@@ -1123,6 +1140,8 @@ static LWGEOM* parse_gml_curve(xmlNodePtr xnode, bool *hasz, int *root_srid)
xmlChar *interpolation=NULL;
if (is_xlink(xnode)) xnode = get_xlink_node(xnode);
+ if (xnode == NULL)
+ gml_lwpgerror("invalid GML representation", 30);
/* Looking for gml:segments */
for (xa = xnode->children ; xa != NULL ; xa = xa->next)
@@ -1229,6 +1248,8 @@ static LWGEOM* parse_gml_linearring(xmlNodePtr xnode, bool *hasz, int *root_srid
POINTARRAY **ppa = NULL;
if (is_xlink(xnode)) xnode = get_xlink_node(xnode);
+ if (xnode == NULL)
+ gml_lwpgerror("invalid GML representation", 30);
parse_gml_srs(xnode, &srs);
ppa = (POINTARRAY**) lwalloc(sizeof(POINTARRAY*));
@@ -1263,6 +1284,8 @@ static LWGEOM* parse_gml_polygon(xmlNodePtr xnode, bool *hasz, int *root_srid)
POINTARRAY **ppa = NULL;
if (is_xlink(xnode)) xnode = get_xlink_node(xnode);
+ if (xnode == NULL)
+ gml_lwpgerror("invalid GML representation", 30);
if (xnode->children == NULL)
return lwpoly_as_lwgeom(lwpoly_construct_empty(*root_srid, 0, 0));
@@ -1357,6 +1380,8 @@ static LWGEOM* parse_gml_triangle(xmlNodePtr xnode, bool *hasz, int *root_srid)
xmlChar *interpolation=NULL;
if (is_xlink(xnode)) xnode = get_xlink_node(xnode);
+ if (xnode == NULL)
+ gml_lwpgerror("invalid GML representation", 30);
if (xnode->children == NULL)
return lwtriangle_as_lwgeom(lwtriangle_construct_empty(*root_srid, 0, 0));
@@ -1523,6 +1548,8 @@ static LWGEOM* parse_gml_surface(xmlNodePtr xnode, bool *hasz, int *root_srid)
bool found=false;
if (is_xlink(xnode)) xnode = get_xlink_node(xnode);
+ if (xnode == NULL)
+ gml_lwpgerror("invalid GML representation", 30);
/* Looking for gml:patches */
for (xa = xnode->children ; xa != NULL ; xa = xa->next)
@@ -1575,6 +1602,8 @@ static LWGEOM* parse_gml_tin(xmlNodePtr xnode, bool *hasz, int *root_srid)
bool found=false;
if (is_xlink(xnode)) xnode = get_xlink_node(xnode);
+ if (xnode == NULL)
+ gml_lwpgerror("invalid GML representation", 30);
parse_gml_srs(xnode, &srs);
if (*root_srid == SRID_UNKNOWN && srs.srid != SRID_UNKNOWN)
@@ -1625,6 +1654,8 @@ static LWGEOM* parse_gml_mpoint(xmlNodePtr xnode, bool *hasz, int *root_srid)
LWGEOM *geom = NULL;
if (is_xlink(xnode)) xnode = get_xlink_node(xnode);
+ if (xnode == NULL)
+ gml_lwpgerror("invalid GML representation", 30);
parse_gml_srs(xnode, &srs);
if (*root_srid == SRID_UNKNOWN && srs.srid != SRID_UNKNOWN)
@@ -1671,6 +1702,10 @@ static LWGEOM* parse_gml_mline(xmlNodePtr xnode, bool *hasz, int *root_srid)
LWGEOM *geom = NULL;
if (is_xlink(xnode)) xnode = get_xlink_node(xnode);
+ if (xnode == NULL)
+ gml_lwpgerror("invalid GML representation", 30);
+ if (xnode == NULL)
+ gml_lwpgerror("invalid GML representation", 30);
parse_gml_srs(xnode, &srs);
if (*root_srid == SRID_UNKNOWN && srs.srid != SRID_UNKNOWN)
@@ -1706,6 +1741,8 @@ static LWGEOM* parse_gml_mcurve(xmlNodePtr xnode, bool *hasz, int *root_srid)
LWGEOM *geom = NULL;
if (is_xlink(xnode)) xnode = get_xlink_node(xnode);
+ if (xnode == NULL)
+ gml_lwpgerror("invalid GML representation", 30);
parse_gml_srs(xnode, &srs);
if (*root_srid == SRID_UNKNOWN && srs.srid != SRID_UNKNOWN)
@@ -1753,6 +1790,8 @@ static LWGEOM* parse_gml_mpoly(xmlNodePtr xnode, bool *hasz, int *root_srid)
LWGEOM *geom = NULL;
if (is_xlink(xnode)) xnode = get_xlink_node(xnode);
+ if (xnode == NULL)
+ gml_lwpgerror("invalid GML representation", 30);
parse_gml_srs(xnode, &srs);
if (*root_srid == SRID_UNKNOWN && srs.srid != SRID_UNKNOWN)
@@ -1788,6 +1827,8 @@ static LWGEOM* parse_gml_msurface(xmlNodePtr xnode, bool *hasz, int *root_srid)
LWGEOM *geom = NULL;
if (is_xlink(xnode)) xnode = get_xlink_node(xnode);
+ if (xnode == NULL)
+ gml_lwpgerror("invalid GML representation", 30);
parse_gml_srs(xnode, &srs);
if (*root_srid == SRID_UNKNOWN && srs.srid != SRID_UNKNOWN)
@@ -1836,6 +1877,8 @@ static LWGEOM* parse_gml_psurface(xmlNodePtr xnode, bool *hasz, int *root_srid)
LWGEOM *geom = NULL;
if (is_xlink(xnode)) xnode = get_xlink_node(xnode);
+ if (xnode == NULL)
+ gml_lwpgerror("invalid GML representation", 30);
parse_gml_srs(xnode, &srs);
if (*root_srid == SRID_UNKNOWN && srs.srid != SRID_UNKNOWN)
-----------------------------------------------------------------------
Summary of changes:
NEWS | 3 ++-
postgis/lwgeom_in_gml.c | 57 +++++++++++++++++++++++++++++++++++++++++++------
2 files changed, 52 insertions(+), 8 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list