]> granicus.if.org Git - postgis/commitdiff
Cleanly handled deserialization of points with non-point input by raising an error...
authorSandro Santilli <strk@keybit.net>
Tue, 18 Apr 2006 10:28:48 +0000 (10:28 +0000)
committerSandro Santilli <strk@keybit.net>
Tue, 18 Apr 2006 10:28:48 +0000 (10:28 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@2330 b70326c6-7e19-0410-871a-916f4a2858ee

lwgeom/liblwgeom.c
lwgeom/lwline.c
lwgeom/lwpoint.c
lwgeom/lwpoly.c

index ab0cd4f4d4b76d658d41e678c7b1332fa1d03e48..ed656ce874a87ccf650a30adcabd2f448aa7385a 100644 (file)
@@ -112,6 +112,11 @@ default_errorreporter(const char *fmt, ...)
 const char *
 lwgeom_typename(int type)
 {
+       // something went wrong somewhere
+       if ( type < 0 || type > 7 ) {
+               // assert(0);
+               return "Invalid type";
+       }
        return lwgeomTypeName[type];
 }
 
index 3716e0762d0b3f4cb40311884795a6e469ec5042..1191c2359d8b561d4c1df84ecea09bffd66515a3 100644 (file)
@@ -50,7 +50,7 @@ lwline_deserialize(uchar *serialized_form)
 
        if ( lwgeom_getType(type) != LINETYPE)
        {
-               lwerror("lwline_deserialize: attempt to deserialize a line when its not really a line");
+               lwerror("lwline_deserialize: attempt to deserialize a line which is really a %s", lwgeom_typename(type));
                return NULL;
        }
 
index 272166cff9cd8f7e13b72e27bb62b18a7ad42f91..9b556ab836e4b61b695a3df9b83de584192eb15b 100644 (file)
@@ -256,7 +256,11 @@ lwpoint_deserialize(uchar *serialized_form)
 
        type = serialized_form[0];
 
-       if ( lwgeom_getType(type) != POINTTYPE) return NULL;
+       if ( lwgeom_getType(type) != POINTTYPE)
+       {
+               lwerror("lwpoint_deserialize: attempt to deserialize a point which is really a %s", lwgeom_typename(type));
+               return NULL;
+       }
        result->type = type;
 
        loc = serialized_form+1;
index d013a13cebf4c1f6a13b3fe3be3496e245ae8a20..606bed1a15a710fa1f87fcaca83cc9cedd82b742 100644 (file)
@@ -84,8 +84,7 @@ lwpoly_deserialize(uchar *serialized_form)
 
        if ( TYPE_GETTYPE(type) != POLYGONTYPE)
        {
-               lwerror("lwpoly_deserialize called with arg of type %d",
-                       lwgeom_getType(type));
+               lwerror("lwpoly_deserialize: attempt to deserialize a poly which is really a %s", lwgeom_typename(type));
                return NULL;
        }