From f93679560a5c48ef3384b642be410fd2dff7747d Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 20 Sep 2004 14:14:43 +0000 Subject: [PATCH] Fixed a bug in popbyte. Trapped WKB endiannes errors. git-svn-id: http://svn.osgeo.org/postgis/trunk@852 b70326c6-7e19-0410-871a-916f4a2858ee --- loader/pgsql2shp.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/loader/pgsql2shp.c b/loader/pgsql2shp.c index 4c6ff9c7f..d76bc1a89 100644 --- a/loader/pgsql2shp.c +++ b/loader/pgsql2shp.c @@ -10,6 +10,9 @@ * ********************************************************************** * $Log$ + * Revision 1.55 2004/09/20 14:14:43 strk + * Fixed a bug in popbyte. Trapped WKB endiannes errors. + * * Revision 1.54 2004/09/20 13:49:27 strk * Postgis-1.x support (LWGEOM) added. * postgis version detected at runtime. @@ -398,9 +401,16 @@ shape_creator_wrapper_WKB(byte *str, int idx) byte *ptr = str; uint32 type; int is3d; + int wkb_big_endian; // skip byte order - skipbyte(&ptr); + //skipbyte(&ptr); + wkb_big_endian = ! popbyte(&ptr); + if ( wkb_big_endian != big_endian ) + { + fprintf(stderr, "Wrong WKB endiannes, dunno how to flip\n"); + exit(1); + } // get type type = getint(ptr); @@ -2462,9 +2472,8 @@ byte getbyte(byte *c) { return *((char*)c); } -// #define popbyte(x) *x++ byte popbyte(byte **c) { - return *((byte*)*c++); + return *((*c)++); } uint32 popint(byte **c) { -- 2.40.0