--- src/core/qgsgeometry.cpp.orig	2012-01-31 16:26:02.963482000 +1300
+++ src/core/qgsgeometry.cpp	2012-02-01 09:42:48.915797000 +1300
@@ -709,7 +709,7 @@
   double actdist = std::numeric_limits<double>::max();
   double x = 0;
   double y = 0;
-  double *tempx, *tempy;
+  double tempx, tempy;
   memcpy( &wkbType, ( mGeometry + 1 ), sizeof( int ) );
   beforeVertex = -1;
   afterVertex = -1;
@@ -720,8 +720,8 @@
     case QGis::WKBPoint25D:
     case QGis::WKBPoint:
     {
-      x = *(( double * )( mGeometry + 5 ) );
-      y = *(( double * )( mGeometry + 5 + sizeof( double ) ) );
+      memcpy( &x, mGeometry + 5, sizeof( x ) );
+      memcpy( &y, mGeometry + 5 + sizeof( double ), sizeof( y ) );
       actdist = point.sqrDist( x, y );
       vertexnr = 0;
       break;
@@ -734,18 +734,19 @@
     case QGis::WKBLineString:
     {
       unsigned char* ptr = mGeometry + 5;
-      int* npoints = ( int* )ptr;
+      int npoints;
+      memcpy( &npoints, ptr, sizeof( npoints ) );
       ptr += sizeof( int );
-      for ( int index = 0; index < *npoints; ++index )
+      for ( int index = 0; index < npoints; ++index )
       {
-        tempx = ( double* )ptr;
+        memcpy( &tempx, ptr, sizeof( tempx ) );
         ptr += sizeof( double );
-        tempy = ( double* )ptr;
-        if ( point.sqrDist( *tempx, *tempy ) < actdist )
+        memcpy( &tempy, ptr, sizeof( tempy ) );
+        if ( point.sqrDist( tempx, tempy ) < actdist )
         {
-          x = *tempx;
-          y = *tempy;
-          actdist = point.sqrDist( *tempx, *tempy );
+          x = tempx;
+          y = tempy;
+          actdist = point.sqrDist( tempx, tempy );
           vertexnr = index;
           if ( index == 0 )//assign the rubber band indices
           {
@@ -755,7 +756,7 @@
           {
             beforeVertex = index - 1;
           }
-          if ( index == ( *npoints - 1 ) )
+          if ( index == ( npoints - 1 ) )
           {
             afterVertex = -1;
           }
@@ -776,34 +777,35 @@
       hasZValue = true;
     case QGis::WKBPolygon:
     {
-      int* nrings = ( int* )( mGeometry + 5 );
-      int* npoints;
+      int nrings;
+      memcpy( &nrings, mGeometry + 5, sizeof( nrings ) );
+      int npoints;
       unsigned char* ptr = mGeometry + 9;
-      for ( int index = 0; index < *nrings; ++index )
+      for ( int index = 0; index < nrings; ++index )
       {
-        npoints = ( int* )ptr;
+        memcpy( &npoints, ptr, sizeof( npoints ) );
         ptr += sizeof( int );
-        for ( int index2 = 0; index2 < *npoints; ++index2 )
+        for ( int index2 = 0; index2 < npoints; ++index2 )
         {
-          tempx = ( double* )ptr;
+          memcpy( &tempx, ptr, sizeof( tempx ) );
           ptr += sizeof( double );
-          tempy = ( double* )ptr;
-          if ( point.sqrDist( *tempx, *tempy ) < actdist )
+          memcpy( &tempy, ptr, sizeof( tempy ) );
+          if ( point.sqrDist( tempx, tempy ) < actdist )
           {
-            x = *tempx;
-            y = *tempy;
-            actdist = point.sqrDist( *tempx, *tempy );
+            x = tempx;
+            y = tempy;
+            actdist = point.sqrDist( tempx, tempy );
             vertexnr = vertexcounter;
             //assign the rubber band indices
             if ( index2 == 0 )
             {
-              beforeVertex = vertexcounter + ( *npoints - 2 );
+              beforeVertex = vertexcounter + ( npoints - 2 );
               afterVertex = vertexcounter + 1;
             }
-            else if ( index2 == ( *npoints - 1 ) )
+            else if ( index2 == ( npoints - 1 ) )
             {
               beforeVertex = vertexcounter - 1;
-              afterVertex = vertexcounter - ( *npoints - 2 );
+              afterVertex = vertexcounter - ( npoints - 2 );
             }
             else
             {
@@ -831,13 +833,13 @@
       for ( int index = 0; index < *npoints; ++index )
       {
         ptr += ( 1 + sizeof( int ) ); //skip endian and point type
-        tempx = ( double* )ptr;
-        tempy = ( double* )( ptr + sizeof( double ) );
-        if ( point.sqrDist( *tempx, *tempy ) < actdist )
-        {
-          x = *tempx;
-          y = *tempy;
-          actdist = point.sqrDist( *tempx, *tempy );
+        memcpy( &tempx, ptr, sizeof( tempx ) );
+        memcpy( &tempy, ptr + sizeof( double ), sizeof( tempy ) );
+        if ( point.sqrDist( tempx, tempy ) < actdist )
+        {
+          x = tempx;
+          y = tempy;
+          actdist = point.sqrDist( tempx, tempy );
           vertexnr = index;
         }
         ptr += ( 2 * sizeof( double ) );
@@ -853,25 +855,26 @@
     case QGis::WKBMultiLineString:
     {
       unsigned char* ptr = mGeometry + 5;
-      int* nlines = ( int* )ptr;
-      int* npoints = 0;
+      int nlines;
+      memcpy( &nlines, ptr, sizeof( nlines ) );
+      int npoints = 0;
       ptr += sizeof( int );
-      for ( int index = 0; index < *nlines; ++index )
+      for ( int index = 0; index < nlines; ++index )
       {
         ptr += ( sizeof( int ) + 1 );
-        npoints = ( int* )ptr;
+        memcpy( &npoints, ptr, sizeof( npoints ) );
         ptr += sizeof( int );
-        for ( int index2 = 0; index2 < *npoints; ++index2 )
+        for ( int index2 = 0; index2 < npoints; ++index2 )
         {
-          tempx = ( double* )ptr;
+          memcpy( &tempx, ptr, sizeof( tempx ) );
           ptr += sizeof( double );
-          tempy = ( double* )ptr;
+          memcpy( &tempy, ptr, sizeof( tempy ) );
           ptr += sizeof( double );
-          if ( point.sqrDist( *tempx, *tempy ) < actdist )
+          if ( point.sqrDist( tempx, tempy ) < actdist )
           {
-            x = *tempx;
-            y = *tempy;
-            actdist = point.sqrDist( *tempx, *tempy );
+            x = tempx;
+            y = tempy;
+            actdist = point.sqrDist( tempx, tempy );
             vertexnr = vertexcounter;
 
             if ( index2 == 0 )//assign the rubber band indices
@@ -882,7 +885,7 @@
             {
               beforeVertex = vertexnr - 1;
             }
-            if ( index2 == ( *npoints ) - 1 )
+            if ( index2 == ( npoints ) - 1 )
             {
               afterVertex = -1;
             }
@@ -905,41 +908,42 @@
     case QGis::WKBMultiPolygon:
     {
       unsigned char* ptr = mGeometry + 5;
-      int* npolys = ( int* )ptr;
-      int* nrings;
-      int* npoints;
+      int npolys;
+      memcpy( &npolys, ptr, sizeof( npolys ) );
+      int nrings;
+      int npoints;
       ptr += sizeof( int );
-      for ( int index = 0; index < *npolys; ++index )
+      for ( int index = 0; index < npolys; ++index )
       {
         ptr += ( 1 + sizeof( int ) ); //skip endian and polygon type
-        nrings = ( int* )ptr;
+        memcpy( &nrings, ptr, sizeof( nrings ) );
         ptr += sizeof( int );
-        for ( int index2 = 0; index2 < *nrings; ++index2 )
+        for ( int index2 = 0; index2 < nrings; ++index2 )
         {
-          npoints = ( int* )ptr;
+          memcpy( &npoints, ptr, sizeof( npoints ) );
           ptr += sizeof( int );
-          for ( int index3 = 0; index3 < *npoints; ++index3 )
+          for ( int index3 = 0; index3 < npoints; ++index3 )
           {
-            tempx = ( double* )ptr;
+            memcpy( &tempx, ptr, sizeof( tempx ) );
             ptr += sizeof( double );
-            tempy = ( double* )ptr;
-            if ( point.sqrDist( *tempx, *tempy ) < actdist )
+            memcpy( &tempy, ptr, sizeof( tempy ) ) ;
+            if ( point.sqrDist( tempx, tempy ) < actdist )
             {
-              x = *tempx;
-              y = *tempy;
-              actdist = point.sqrDist( *tempx, *tempy );
+              x = tempx;
+              y = tempy;
+              actdist = point.sqrDist( tempx, tempy );
               vertexnr = vertexcounter;
 
               //assign the rubber band indices
               if ( index3 == 0 )
               {
-                beforeVertex = vertexcounter + ( *npoints - 2 );
+                beforeVertex = vertexcounter + ( npoints - 2 );
                 afterVertex = vertexcounter + 1;
               }
-              else if ( index3 == ( *npoints - 1 ) )
+              else if ( index3 == ( npoints - 1 ) )
               {
                 beforeVertex = vertexcounter - 1;
-                afterVertex = vertexcounter - ( *npoints - 2 );
+                afterVertex = vertexcounter - ( npoints - 2 );
               }
               else
               {
@@ -1002,7 +1006,8 @@
     case QGis::WKBLineString:
     {
       unsigned char* ptr = mGeometry + 5;
-      int* npoints = ( int* ) ptr;
+      int npoints;
+      memcpy( &npoints, ptr, sizeof( npoints ) );
 
       const int index = atVertex;
 
@@ -1017,7 +1022,7 @@
         beforeVertex = index - 1;
       }
 
-      if ( index == ( *npoints - 1 ) )
+      if ( index == ( npoints - 1 ) )
       {
         afterVertex = -1;
       }
@@ -1032,18 +1037,19 @@
       hasZValue = true;
     case QGis::WKBPolygon:
     {
-      int* nrings = ( int* )( mGeometry + 5 );
-      int* npoints;
+      int nrings;
+      memcpy( &nrings, mGeometry + 5, sizeof( nrings ) );
+      int npoints;
       unsigned char* ptr = mGeometry + 9;
 
       // Walk through the POLYGON WKB
 
-      for ( int index0 = 0; index0 < *nrings; ++index0 )
+      for ( int index0 = 0; index0 < nrings; ++index0 )
       {
-        npoints = ( int* )ptr;
+        memcpy( &npoints, ptr, sizeof( npoints ) );
         ptr += sizeof( int );
 
-        for ( int index1 = 0; index1 < *npoints; ++index1 )
+        for ( int index1 = 0; index1 < npoints; ++index1 )
         {
           ptr += sizeof( double );
           ptr += sizeof( double );
@@ -1055,13 +1061,13 @@
           {
             if ( index1 == 0 )
             {
-              beforeVertex = vertexcounter + ( *npoints - 2 );
+              beforeVertex = vertexcounter + ( npoints - 2 );
               afterVertex = vertexcounter + 1;
             }
-            else if ( index1 == ( *npoints - 1 ) )
+            else if ( index1 == ( npoints - 1 ) )
             {
               beforeVertex = vertexcounter - 1;
-              afterVertex = vertexcounter - ( *npoints - 2 );
+              afterVertex = vertexcounter - ( npoints - 2 );
             }
             else
             {
@@ -1087,17 +1093,18 @@
     case QGis::WKBMultiLineString:
     {
       unsigned char* ptr = mGeometry + 5;
-      int* nlines = ( int* )ptr;
-      int* npoints = 0;
+      int nlines;
+      memcpy( &nlines, ptr, sizeof( nlines ) );
+      int npoints = 0;
       ptr += sizeof( int );
 
-      for ( int index0 = 0; index0 < *nlines; ++index0 )
+      for ( int index0 = 0; index0 < nlines; ++index0 )
       {
         ptr += ( sizeof( int ) + 1 );
-        npoints = ( int* )ptr;
+        memcpy( &npoints, ptr, sizeof( npoints ) );
         ptr += sizeof( int );
 
-        for ( int index1 = 0; index1 < *npoints; ++index1 )
+        for ( int index1 = 0; index1 < npoints; ++index1 )
         {
           ptr += sizeof( double );
           ptr += sizeof( double );
@@ -1117,7 +1124,7 @@
             {
               beforeVertex = vertexcounter - 1;
             }
-            if ( index1 == ( *npoints ) - 1 )
+            if ( index1 == ( npoints ) - 1 )
             {
               afterVertex = -1;
             }
@@ -1136,23 +1143,24 @@
     case QGis::WKBMultiPolygon:
     {
       unsigned char* ptr = mGeometry + 5;
-      int* npolys = ( int* )ptr;
-      int* nrings;
-      int* npoints;
+      int npolys;
+      memcpy( &npolys, ptr, sizeof( npolys ) );
+      int nrings;
+      int npoints;
       ptr += sizeof( int );
 
-      for ( int index0 = 0; index0 < *npolys; ++index0 )
+      for ( int index0 = 0; index0 < npolys; ++index0 )
       {
         ptr += ( 1 + sizeof( int ) ); //skip endian and polygon type
-        nrings = ( int* )ptr;
+        memcpy( &nrings, ptr, sizeof( nrings ) );
         ptr += sizeof( int );
 
-        for ( int index1 = 0; index1 < *nrings; ++index1 )
+        for ( int index1 = 0; index1 < nrings; ++index1 )
         {
-          npoints = ( int* )ptr;
+          memcpy( &npoints, ptr, sizeof( npoints ) );
           ptr += sizeof( int );
 
-          for ( int index2 = 0; index2 < *npoints; ++index2 )
+          for ( int index2 = 0; index2 < npoints; ++index2 )
           {
             ptr += sizeof( double );
             ptr += sizeof( double );
@@ -1167,13 +1175,13 @@
 
               if ( index2 == 0 )
               {
-                beforeVertex = vertexcounter + ( *npoints - 2 );
+                beforeVertex = vertexcounter + ( npoints - 2 );
                 afterVertex = vertexcounter + 1;
               }
-              else if ( index2 == ( *npoints - 1 ) )
+              else if ( index2 == ( npoints - 1 ) )
               {
                 beforeVertex = vertexcounter - 1;
-                afterVertex = vertexcounter - ( *npoints - 2 );
+                afterVertex = vertexcounter - ( npoints - 2 );
               }
               else
               {
@@ -3435,11 +3443,11 @@
   double xmax = -std::numeric_limits<double>::max();
   double ymax = -std::numeric_limits<double>::max();
 
-  double *x;
-  double *y;
-  int *nPoints;
-  int *numRings;
-  int *numPolygons;
+  double x;
+  double y;
+  int nPoints;
+  int numRings;
+  int numPolygons;
   int numLineStrings;
   int idx, jdx, kdx;
   unsigned char *ptr;
@@ -3465,23 +3473,23 @@
   {
     case QGis::WKBPoint25D:
     case QGis::WKBPoint:
-      x = ( double * )( mGeometry + 5 );
-      y = ( double * )( mGeometry + 5 + sizeof( double ) );
-      if ( *x < xmin )
+      memcpy( &x, mGeometry + 5, sizeof( x ) );
+      memcpy( &y, mGeometry + 5 + sizeof( double ), sizeof( y ) );
+      if ( x < xmin )
       {
-        xmin = *x;
+        xmin = x;
       }
-      if ( *x > xmax )
+      if ( x > xmax )
       {
-        xmax = *x;
+        xmax = x;
       }
-      if ( *y < ymin )
+      if ( y < ymin )
       {
-        ymin = *y;
+        ymin = y;
       }
-      if ( *y > ymax )
+      if ( y > ymax )
       {
-        ymax = *y;
+        ymax = y;
       }
       break;
     case QGis::WKBMultiPoint25D:
@@ -3489,34 +3497,34 @@
     case QGis::WKBMultiPoint:
     {
       ptr = mGeometry + 1 + sizeof( int );
-      nPoints = ( int * ) ptr;
+      memcpy( &nPoints, ptr, sizeof( nPoints ) );
       ptr += sizeof( int );
-      for ( idx = 0; idx < *nPoints; idx++ )
+      for ( idx = 0; idx < nPoints; idx++ )
       {
-        ptr += ( 1 + sizeof( int ) );
-        x = ( double * ) ptr;
+        ptr +=1 + sizeof( int );
+        memcpy( &x, ptr, sizeof( x ) );
         ptr += sizeof( double );
-        y = ( double * ) ptr;
+        memcpy( &y, ptr, sizeof( y ) );
         ptr += sizeof( double );
         if ( hasZValue )
         {
           ptr += sizeof( double );
         }
-        if ( *x < xmin )
+        if ( x < xmin )
         {
-          xmin = *x;
+          xmin = x;
         }
-        if ( *x > xmax )
+        if ( x > xmax )
         {
-          xmax = *x;
+          xmax = x;
         }
-        if ( *y < ymin )
+        if ( y < ymin )
         {
-          ymin = *y;
+          ymin = y;
         }
-        if ( *y > ymax )
+        if ( y > ymax )
         {
-          ymax = *y;
+          ymax = y;
         }
       }
       break;
@@ -3527,33 +3535,33 @@
     {
       // get number of points in the line
       ptr = mGeometry + 5;
-      nPoints = ( int * ) ptr;
+      memcpy( &nPoints, ptr, sizeof( nPoints ) );
       ptr = mGeometry + 1 + 2 * sizeof( int );
-      for ( idx = 0; idx < *nPoints; idx++ )
+      for ( idx = 0; idx < nPoints; idx++ )
       {
-        x = ( double * ) ptr;
+        memcpy( &x, ptr, sizeof( x ) );
         ptr += sizeof( double );
-        y = ( double * ) ptr;
+        memcpy( &y, ptr, sizeof( y ) );
         ptr += sizeof( double );
         if ( hasZValue )
         {
           ptr += sizeof( double );
         }
-        if ( *x < xmin )
+        if ( x < xmin )
         {
-          xmin = *x;
+          xmin = x;
         }
-        if ( *x > xmax )
+        if ( x > xmax )
         {
-          xmax = *x;
+          xmax = x;
         }
-        if ( *y < ymin )
+        if ( y < ymin )
         {
-          ymin = *y;
+          ymin = y;
         }
-        if ( *y > ymax )
+        if ( y > ymax )
         {
-          ymax = *y;
+          ymax = y;
         }
       }
       break;
@@ -3568,33 +3576,33 @@
       {
         // each of these is a wbklinestring so must handle as such
         ptr += 5;   // skip type since we know its 2
-        nPoints = ( int * ) ptr;
+        memcpy( &nPoints, ptr, sizeof( nPoints ) );
         ptr += sizeof( int );
-        for ( idx = 0; idx < *nPoints; idx++ )
+        for ( idx = 0; idx < nPoints; idx++ )
         {
-          x = ( double * ) ptr;
+          memcpy( &x, ptr, sizeof( x ) );
           ptr += sizeof( double );
-          y = ( double * ) ptr;
+          memcpy( &y, ptr, sizeof( y ) );
           ptr += sizeof( double );
           if ( hasZValue )
           {
             ptr += sizeof( double );
           }
-          if ( *x < xmin )
+          if ( x < xmin )
           {
-            xmin = *x;
+            xmin = x;
           }
-          if ( *x > xmax )
+          if ( x > xmax )
           {
-            xmax = *x;
+            xmax = x;
           }
-          if ( *y < ymin )
+          if ( y < ymin )
           {
-            ymin = *y;
+            ymin = y;
           }
-          if ( *y > ymax )
+          if ( y > ymax )
           {
-            ymax = *y;
+            ymax = y;
           }
         }
       }
@@ -3605,39 +3613,40 @@
     case QGis::WKBPolygon:
     {
       // get number of rings in the polygon
-      numRings = ( int * )( mGeometry + 1 + sizeof( int ) );
+      ptr = mGeometry + 1 + sizeof( int );
+      memcpy( &numRings, ptr, sizeof( numRings ) );
       ptr = mGeometry + 1 + 2 * sizeof( int );
-      for ( idx = 0; idx < *numRings; idx++ )
+      for ( idx = 0; idx < numRings; idx++ )
       {
         // get number of points in the ring
-        nPoints = ( int * ) ptr;
+        memcpy( &nPoints, ptr, sizeof( nPoints ) );
         ptr += 4;
-        for ( jdx = 0; jdx < *nPoints; jdx++ )
+        for ( jdx = 0; jdx < nPoints; jdx++ )
         {
           // add points to a point array for drawing the polygon
-          x = ( double * ) ptr;
+          memcpy( &x, ptr, sizeof( x ) );
           ptr += sizeof( double );
-          y = ( double * ) ptr;
+          memcpy( &y, ptr, sizeof( y ) );
           ptr += sizeof( double );
           if ( hasZValue )
           {
             ptr += sizeof( double );
           }
-          if ( *x < xmin )
+          if ( x < xmin )
           {
-            xmin = *x;
+            xmin = x;
           }
-          if ( *x > xmax )
+          if ( x > xmax )
           {
-            xmax = *x;
+            xmax = x;
           }
-          if ( *y < ymin )
+          if ( y < ymin )
           {
-            ymin = *y;
+            ymin = y;
           }
-          if ( *y > ymax )
+          if ( y > ymax )
           {
-            ymax = *y;
+            ymax = y;
           }
         }
       }
@@ -3649,47 +3658,47 @@
     {
       // get the number of polygons
       ptr = mGeometry + 5;
-      numPolygons = ( int * ) ptr;
+      memcpy( &numPolygons, ptr, sizeof( numPolygons ) );
       ptr += 4;
 
-      for ( kdx = 0; kdx < *numPolygons; kdx++ )
+      for ( kdx = 0; kdx < numPolygons; kdx++ )
       {
         //skip the endian and mGeometry type info and
         // get number of rings in the polygon
         ptr += 5;
-        numRings = ( int * ) ptr;
+        memcpy( &numRings, ptr, sizeof( numRings ) );
         ptr += 4;
-        for ( idx = 0; idx < *numRings; idx++ )
+        for ( idx = 0; idx < numRings; idx++ )
         {
           // get number of points in the ring
-          nPoints = ( int * ) ptr;
+          memcpy( &nPoints, ptr, sizeof( nPoints ) );
           ptr += 4;
-          for ( jdx = 0; jdx < *nPoints; jdx++ )
+          for ( jdx = 0; jdx < nPoints; jdx++ )
           {
             // add points to a point array for drawing the polygon
-            x = ( double * ) ptr;
+            memcpy( &x, ptr, sizeof( x ) );
             ptr += sizeof( double );
-            y = ( double * ) ptr;
+            memcpy( &y, ptr, sizeof( y ) );
             ptr += sizeof( double );
             if ( hasZValue )
             {
               ptr += sizeof( double );
             }
-            if ( *x < xmin )
+            if ( x < xmin )
             {
-              xmin = *x;
+              xmin = x;
             }
-            if ( *x > xmax )
+            if ( x > xmax )
             {
-              xmax = *x;
+              xmax = x;
             }
-            if ( *y < ymin )
+            if ( y < ymin )
             {
-              ymin = *y;
+              ymin = y;
             }
-            if ( *y > ymax )
+            if ( y > ymax )
             {
-              ymax = *y;
+              ymax = y;
             }
           }
         }
@@ -3839,7 +3848,7 @@
 
   QGis::WkbType wkbType;
   bool hasZValue = false;
-  double *x, *y;
+  double x, y;
 
   QString mWkt; // TODO: rename
 
@@ -3853,11 +3862,11 @@
     case QGis::WKBPoint:
     {
       mWkt += "POINT(";
-      x = ( double * )( mGeometry + 5 );
-      mWkt += QString::number( *x, 'f', 6 );
+      memcpy( &x,  mGeometry + 5, sizeof( x ) );
+      mWkt += QString::number( x, 'f', 6 );
       mWkt += " ";
-      y = ( double * )( mGeometry + 5 + sizeof( double ) );
-      mWkt += QString::number( *y, 'f', 6 );
+      memcpy( &y, mGeometry + 5 + sizeof( double ), sizeof( y ) );
+      mWkt += QString::number( y, 'f', 6 );
       mWkt += ")";
       return mWkt;
     }
@@ -3868,26 +3877,26 @@
     {
       QgsDebugMsg( "LINESTRING found" );
       unsigned char *ptr;
-      int *nPoints;
+      int nPoints;
       int idx;
 
       mWkt += "LINESTRING(";
       // get number of points in the line
       ptr = mGeometry + 5;
-      nPoints = ( int * ) ptr;
+      memcpy( &nPoints, ptr, sizeof( nPoints ) );
       ptr = mGeometry + 1 + 2 * sizeof( int );
-      for ( idx = 0; idx < *nPoints; ++idx )
+      for ( idx = 0; idx < nPoints; ++idx )
       {
         if ( idx != 0 )
         {
           mWkt += ", ";
         }
-        x = ( double * ) ptr;
-        mWkt += QString::number( *x, 'f', 6 );
+        memcpy( &x, ptr, sizeof( x ) );
+        mWkt += QString::number( x, 'f', 6 );
         mWkt += " ";
         ptr += sizeof( double );
-        y = ( double * ) ptr;
-        mWkt += QString::number( *y, 'f', 6 );
+        memcpy( &y, ptr, sizeof( y ) );
+        mWkt += QString::number( y, 'f', 6 );
         ptr += sizeof( double );
         if ( hasZValue )
         {
@@ -3905,21 +3914,21 @@
       QgsDebugMsg( "POLYGON found" );
       unsigned char *ptr;
       int idx, jdx;
-      int *numRings, *nPoints;
+      int numRings, nPoints;
 
       mWkt += "POLYGON(";
       // get number of rings in the polygon
-      numRings = ( int * )( mGeometry + 1 + sizeof( int ) );
-      if ( !( *numRings ) )  // sanity check for zero rings in polygon
+      memcpy( &numRings, mGeometry + 1 + sizeof( int ), sizeof( numRings ) );
+      if ( !( numRings ) )  // sanity check for zero rings in polygon
       {
         return QString();
       }
       int *ringStart; // index of first point for each ring
       int *ringNumPoints; // number of points in each ring
-      ringStart = new int[*numRings];
-      ringNumPoints = new int[*numRings];
+      ringStart = new int[numRings];
+      ringNumPoints = new int[numRings];
       ptr = mGeometry + 1 + 2 * sizeof( int ); // set pointer to the first ring
-      for ( idx = 0; idx < *numRings; idx++ )
+      for ( idx = 0; idx < numRings; idx++ )
       {
         if ( idx != 0 )
         {
@@ -3927,22 +3936,22 @@
         }
         mWkt += "(";
         // get number of points in the ring
-        nPoints = ( int * ) ptr;
-        ringNumPoints[idx] = *nPoints;
+        memcpy( &nPoints, ptr, sizeof( nPoints ) );
+        ringNumPoints[idx] = nPoints;
         ptr += 4;
 
-        for ( jdx = 0; jdx < *nPoints; jdx++ )
+        for ( jdx = 0; jdx < nPoints; jdx++ )
         {
           if ( jdx != 0 )
           {
             mWkt += ",";
           }
-          x = ( double * ) ptr;
-          mWkt += QString::number( *x, 'f', 6 );
+          memcpy( &x, ptr, sizeof( x ) );
+          mWkt += QString::number( x, 'f', 6 );
           mWkt += " ";
           ptr += sizeof( double );
-          y = ( double * ) ptr;
-          mWkt += QString::number( *y, 'f', 6 );
+          memcpy( &y, ptr, sizeof( y ) );
+          mWkt += QString::number( y, 'f', 6 );
           ptr += sizeof( double );
           if ( hasZValue )
           {
@@ -3963,24 +3972,24 @@
     {
       unsigned char *ptr;
       int idx;
-      int *nPoints;
+      int nPoints;
 
       mWkt += "MULTIPOINT(";
-      nPoints = ( int* )( mGeometry + 5 );
+      memcpy( &nPoints, mGeometry + 5, sizeof( nPoints ) );
       ptr = mGeometry + 5 + sizeof( int );
-      for ( idx = 0; idx < *nPoints; ++idx )
+      for ( idx = 0; idx < nPoints; ++idx )
       {
         ptr += ( 1 + sizeof( int ) );
         if ( idx != 0 )
         {
           mWkt += ", ";
         }
-        x = ( double * )( ptr );
-        mWkt += QString::number( *x, 'f', 6 );
+        memcpy( &x, ptr, sizeof( x ) );
+        mWkt += QString::number( x, 'f', 6 );
         mWkt += " ";
         ptr += sizeof( double );
-        y = ( double * )( ptr );
-        mWkt += QString::number( *y, 'f', 6 );
+        memcpy( &y, ptr, sizeof( y ) );
+        mWkt += QString::number( y, 'f', 6 );
         ptr += sizeof( double );
         if ( hasZValue )
         {
@@ -3998,7 +4007,7 @@
       QgsDebugMsg( "MULTILINESTRING found" );
       unsigned char *ptr;
       int idx, jdx, numLineStrings;
-      int *nPoints;
+      int nPoints;
 
       mWkt += "MULTILINESTRING(";
       numLineStrings = ( int )( mGeometry[5] );
@@ -4011,20 +4020,20 @@
         }
         mWkt += "(";
         ptr += 5; // skip type since we know its 2
-        nPoints = ( int * ) ptr;
+        memcpy( &nPoints, ptr, sizeof( nPoints ) );
         ptr += sizeof( int );
-        for ( idx = 0; idx < *nPoints; idx++ )
+        for ( idx = 0; idx < nPoints; idx++ )
         {
           if ( idx != 0 )
           {
             mWkt += ", ";
           }
-          x = ( double * ) ptr;
-          mWkt += QString::number( *x, 'f', 6 );
+          memcpy( &x, ptr, sizeof( x ) );
+          mWkt += QString::number( x, 'f', 6 );
           ptr += sizeof( double );
           mWkt += " ";
-          y = ( double * ) ptr;
-          mWkt += QString::number( *y, 'f', 6 );
+          memcpy( &y, ptr, sizeof( y ) );
+          mWkt += QString::number( y, 'f', 6 );
           ptr += sizeof( double );
           if ( hasZValue )
           {
@@ -4044,13 +4053,13 @@
       QgsDebugMsg( "MULTIPOLYGON found" );
       unsigned char *ptr;
       int idx, jdx, kdx;
-      int *numPolygons, *numRings, *nPoints;
+      int numPolygons, numRings, nPoints;
 
       mWkt += "MULTIPOLYGON(";
       ptr = mGeometry + 5;
-      numPolygons = ( int * ) ptr;
+      memcpy( &numPolygons, ptr, sizeof( numPolygons ) );
       ptr = mGeometry + 9;
-      for ( kdx = 0; kdx < *numPolygons; kdx++ )
+      for ( kdx = 0; kdx < numPolygons; kdx++ )
       {
         if ( kdx != 0 )
         {
@@ -4058,29 +4067,29 @@
         }
         mWkt += "(";
         ptr += 5;
-        numRings = ( int * ) ptr;
+        memcpy( &numRings, ptr, sizeof( numRings ) );
         ptr += 4;
-        for ( idx = 0; idx < *numRings; idx++ )
+        for ( idx = 0; idx < numRings; idx++ )
         {
           if ( idx != 0 )
           {
             mWkt += ",";
           }
           mWkt += "(";
-          nPoints = ( int * ) ptr;
+          memcpy( &nPoints, ptr, sizeof( nPoints ) );
           ptr += 4;
-          for ( jdx = 0; jdx < *nPoints; jdx++ )
+          for ( jdx = 0; jdx < nPoints; jdx++ )
           {
             if ( jdx != 0 )
             {
               mWkt += ",";
             }
-            x = ( double * ) ptr;
-            mWkt += QString::number( *x, 'f', 6 );
+            memcpy( &x, ptr, sizeof( x ) );
+            mWkt += QString::number( x, 'f', 6 );
             ptr += sizeof( double );
             mWkt += " ";
-            y = ( double * ) ptr;
-            mWkt += QString::number( *y, 'f', 6 );
+            memcpy( &y, ptr, sizeof( y ) );
+            mWkt += QString::number( y, 'f', 6 );
             ptr += sizeof( double );
             if ( hasZValue )
             {
@@ -4125,11 +4134,11 @@
     return true;
   }
 
-  double *x;
-  double *y;
-  int *nPoints;
-  int *numRings;
-  int *numPolygons;
+  double x;
+  double y;
+  int nPoints;
+  int numRings;
+  int numPolygons;
   int numLineStrings;
   int idx, jdx, kdx;
   unsigned char *ptr;
@@ -4147,10 +4156,10 @@
       case QGis::WKBPoint25D:
       case QGis::WKBPoint:
       {
-        x = ( double * )( mGeometry + 5 );
-        y = ( double * )( mGeometry + 5 + sizeof( double ) );
+        memcpy( &x, mGeometry + 5, sizeof( x ) );
+        memcpy( &y, mGeometry + 5 + sizeof( double ), sizeof( x ) );
 
-        mGeos = createGeosPoint( QgsPoint( *x, *y ) );
+        mGeos = createGeosPoint( QgsPoint( x, y ) );
         mDirtyGeos = false;
         break;
       }
@@ -4162,20 +4171,20 @@
         QVector<GEOSGeometry *> points;
 
         ptr = mGeometry + 5;
-        nPoints = ( int * ) ptr;
+        memcpy( &nPoints, ptr, sizeof( nPoints ) );
         ptr = mGeometry + 1 + 2 * sizeof( int );
-        for ( idx = 0; idx < *nPoints; idx++ )
+        for ( idx = 0; idx < nPoints; idx++ )
         {
           ptr += ( 1 + sizeof( int ) );
-          x = ( double * ) ptr;
+          memcpy( &x, ptr, sizeof( x ) );
           ptr += sizeof( double );
-          y = ( double * ) ptr;
+          memcpy( &y, ptr, sizeof( y ) );
           ptr += sizeof( double );
           if ( hasZValue )
           {
             ptr += sizeof( double );
           }
-          points << createGeosPoint( QgsPoint( *x, *y ) );
+          points << createGeosPoint( QgsPoint( x, y ) );
         }
         mGeos = createGeosCollection( GEOS_MULTIPOINT, points );
         mDirtyGeos = false;
@@ -4191,20 +4200,20 @@
         QgsPolyline sequence;
 
         ptr = mGeometry + 5;
-        nPoints = ( int * ) ptr;
+        memcpy( &nPoints, ptr, sizeof( nPoints ) );
         ptr = mGeometry + 1 + 2 * sizeof( int );
-        for ( idx = 0; idx < *nPoints; idx++ )
+        for ( idx = 0; idx < nPoints; idx++ )
         {
-          x = ( double * ) ptr;
+          memcpy( &x, ptr, sizeof( x ) );
           ptr += sizeof( double );
-          y = ( double * ) ptr;
+          memcpy( &y, ptr, sizeof( y ) );
           ptr += sizeof( double );
           if ( hasZValue )
           {
             ptr += sizeof( double );
           }
 
-          sequence << QgsPoint( *x, *y );
+          sequence << QgsPoint( x, y );
         }
         mDirtyGeos = false;
         mGeos = createGeosLineString( sequence );
@@ -4224,19 +4233,19 @@
 
           // each of these is a wbklinestring so must handle as such
           ptr += 5;   // skip type since we know its 2
-          nPoints = ( int * ) ptr;
+          memcpy( &nPoints, ptr, sizeof( nPoints ) );
           ptr += sizeof( int );
-          for ( idx = 0; idx < *nPoints; idx++ )
+          for ( idx = 0; idx < nPoints; idx++ )
           {
-            x = ( double * ) ptr;
+            memcpy( &x, ptr, sizeof( x ) );
             ptr += sizeof( double );
-            y = ( double * ) ptr;
+            memcpy( &y, ptr, sizeof( y ) );
             ptr += sizeof( double );
             if ( hasZValue )
             {
               ptr += sizeof( double );
             }
-            sequence << QgsPoint( *x, *y );
+            sequence << QgsPoint( x, y );
           }
           lines << createGeosLineString( sequence );
         }
@@ -4252,32 +4261,32 @@
         QgsDebugMsgLevel( "Polygon found", 3 );
 
         // get number of rings in the polygon
-        numRings = ( int * )( mGeometry + 1 + sizeof( int ) );
+        memcpy( &numRings, mGeometry + 1 + sizeof( int ), sizeof( numRings ) );
         ptr = mGeometry + 1 + 2 * sizeof( int );
 
         QVector<GEOSGeometry*> rings;
 
-        for ( idx = 0; idx < *numRings; idx++ )
+        for ( idx = 0; idx < numRings; idx++ )
         {
           //QgsDebugMsg("Ring nr: "+QString::number(idx));
 
           QgsPolyline sequence;
 
           // get number of points in the ring
-          nPoints = ( int * ) ptr;
+          memcpy( &nPoints, ptr, sizeof( nPoints ) );
           ptr += 4;
-          for ( jdx = 0; jdx < *nPoints; jdx++ )
+          for ( jdx = 0; jdx < nPoints; jdx++ )
           {
             // add points to a point array for drawing the polygon
-            x = ( double * ) ptr;
+            memcpy( &x, ptr, sizeof( x ) );
             ptr += sizeof( double );
-            y = ( double * ) ptr;
+            memcpy( &y, ptr, sizeof( y ) );
             ptr += sizeof( double );
             if ( hasZValue )
             {
               ptr += sizeof( double );
             }
-            sequence << QgsPoint( *x, *y );
+            sequence << QgsPoint( x, y );
           }
 
           rings << createGeosLinearRing( sequence );
@@ -4297,9 +4306,9 @@
 
         // get the number of polygons
         ptr = mGeometry + 5;
-        numPolygons = ( int * ) ptr;
+        memcpy( &numPolygons, ptr, sizeof( numPolygons ) );
         ptr = mGeometry + 9;
-        for ( kdx = 0; kdx < *numPolygons; kdx++ )
+        for ( kdx = 0; kdx < numPolygons; kdx++ )
         {
           //QgsDebugMsg("Polygon nr: "+QString::number(kdx));
           QVector<GEOSGeometry*> rings;
@@ -4307,29 +4316,29 @@
           //skip the endian and mGeometry type info and
           // get number of rings in the polygon
           ptr += 5;
-          numRings = ( int * ) ptr;
+          memcpy( &numRings, ptr, sizeof( numRings ) );
           ptr += 4;
-          for ( idx = 0; idx < *numRings; idx++ )
+          for ( idx = 0; idx < numRings; idx++ )
           {
             //QgsDebugMsg("Ring nr: "+QString::number(idx));
 
             QgsPolyline sequence;
 
             // get number of points in the ring
-            nPoints = ( int * ) ptr;
+            memcpy( &nPoints, ptr, sizeof( nPoints ) );
             ptr += 4;
-            for ( jdx = 0; jdx < *nPoints; jdx++ )
+            for ( jdx = 0; jdx < nPoints; jdx++ )
             {
               // add points to a point array for drawing the polygon
-              x = ( double * ) ptr;
+              memcpy( &x, ptr, sizeof( x ) );
               ptr += sizeof( double );
-              y = ( double * ) ptr;
+              memcpy( &y, ptr, sizeof( y ) );
               ptr += sizeof( double );
               if ( hasZValue )
               {
                 ptr += sizeof( double );
               }
-              sequence << QgsPoint( *x, *y );
+              sequence << QgsPoint( x, y );
             }
 
             rings << createGeosLinearRing( sequence );
@@ -5834,7 +5843,8 @@
   bool hasZValue = ( type == QGis::WKBMultiPoint25D );
 
   unsigned char* ptr = mGeometry + 5;
-  unsigned int nPoints = *(( int* )ptr );
+  unsigned int nPoints;
+  memcpy( &nPoints, ptr, sizeof( nPoints ) );
   ptr += 4;
 
   QgsMultiPoint points( nPoints );
@@ -5855,7 +5865,8 @@
   bool hasZValue = ( type == QGis::WKBMultiLineString25D );
 
   unsigned char* ptr = mGeometry + 5;
-  unsigned int numLineStrings = *(( int* )ptr );
+  unsigned int numLineStrings;
+  memcpy( &numLineStrings, ptr, sizeof( numLineStrings ) );
   ptr += 4;
 
   QgsMultiPolyline lines( numLineStrings );
@@ -5877,7 +5888,8 @@
   bool hasZValue = ( type == QGis::WKBMultiPolygon25D );
 
   unsigned char* ptr = mGeometry + 5;
-  unsigned int numPolygons = *(( int* )ptr );
+  unsigned int numPolygons;
+  memcpy( &numPolygons, ptr, sizeof( numPolygons ) );
   ptr += 4;
 
   QgsMultiPolygon polygons( numPolygons );
