]> granicus.if.org Git - postgis/commitdiff
Guard against null return and avoid leaking PJ object
authorPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 22 Feb 2019 23:40:42 +0000 (23:40 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 22 Feb 2019 23:40:42 +0000 (23:40 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@17276 b70326c6-7e19-0410-871a-916f4a2858ee

libpgcommon/lwgeom_transform.c

index 3962c72cdd88db6dec9c4a42bb6837ad3c422ee5..5eb6e08db22e1d499bed06e96f0910090c388283 100644 (file)
@@ -864,14 +864,18 @@ GetPJUsingFCInfo(FunctionCallInfo fcinfo, int srid_from, int srid_to, PJ** pj)
        return LW_SUCCESS;
 }
 
-
 static int
 proj_pj_is_latlong(const PJ* pj)
 {
 #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