]> granicus.if.org Git - postgis/commitdiff
Crash in ST_Project on NULL input (#1658)
authorPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 7 Mar 2012 05:31:24 +0000 (05:31 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 7 Mar 2012 05:31:24 +0000 (05:31 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9414 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/geography_measurement.c

index 063e350ac1355deb4e8ab585bab6306308f7426d..a8b859cf2177ce8bfee736abe64d0c0c9546b456 100644 (file)
@@ -611,6 +611,10 @@ Datum geography_project(PG_FUNCTION_ARGS)
        SPHEROID s;
        uint32_t type;
 
+       /* Return NULL on NULL distance or geography */
+       if ( PG_ARGISNULL(0) || PG_ARGISNULL(1) )
+               PG_RETURN_NULL();
+       
        /* Get our geometry object loaded into memory. */
        g = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
        
@@ -622,10 +626,6 @@ Datum geography_project(PG_FUNCTION_ARGS)
                PG_RETURN_NULL();
     }
 
-       /* Return NULL on NULL distance */
-       if ( PG_ARGISNULL(1) )
-               PG_RETURN_NULL();
-       
        distance = PG_GETARG_FLOAT8(1); /* Distance in Meters */
        lwgeom = lwgeom_from_gserialized(g);