[postgis-tickets] r17276 - Guard against null return and avoid leaking PJ object
Paul Ramsey
pramsey at cleverelephant.ca
Fri Feb 22 03:40:42 PST 2019
Author: pramsey
Date: 2019-02-22 15:40:42 -0800 (Fri, 22 Feb 2019)
New Revision: 17276
Modified:
trunk/libpgcommon/lwgeom_transform.c
Log:
Guard against null return and avoid leaking PJ object
Modified: trunk/libpgcommon/lwgeom_transform.c
===================================================================
--- trunk/libpgcommon/lwgeom_transform.c 2019-02-22 23:05:32 UTC (rev 17275)
+++ trunk/libpgcommon/lwgeom_transform.c 2019-02-22 23:40:42 UTC (rev 17276)
@@ -864,7 +864,6 @@
return LW_SUCCESS;
}
-
static int
proj_pj_is_latlong(const PJ* pj)
{
@@ -871,7 +870,12 @@
#if POSTGIS_PROJ_VERSION < 60
return pj_is_latlong(pj->pj_from);
#else
- PJ_TYPE pj_type = proj_get_type(proj_get_source_crs(NULL, pj));
+ PJ_TYPE pj_type;
+ PJ *pj_src_crs = proj_get_source_crs(NULL, pj);
+ if (!pj_src_crs)
+ elog(ERROR, "%s: proj_get_source_crs returned NULL", __func__);
+ pj_type = proj_get_type(pj_src_crs);
+ proj_destroy(pj_src_crs);
return (pj_type == PJ_TYPE_GEOGRAPHIC_2D_CRS) ||
(pj_type == PJ_TYPE_GEOGRAPHIC_3D_CRS);
#endif
More information about the postgis-tickets
mailing list