qgsdistancearea.cpp.patch

Patch to address these issues for this file - Sam Gillingham, 2012-04-18 05:15 PM

Download (2.33 KB)

View differences:

./src/core/qgsdistancearea.cpp Thu Apr 19 11:47:32 2012
208 208
    case QGis::WKBMultiLineString25D:
209 209
      hasZptr = true;
210 210
    case QGis::WKBMultiLineString:
211
      count = *(( int* )( wkb + 5 ) );
211
      memcpy( &count, wkb + 5, sizeof( count ) );
212 212
      ptr = wkb + 9;
213 213
      for ( i = 0; i < count; i++ )
214 214
      {
......
228 228
    case QGis::WKBMultiPolygon25D:
229 229
      hasZptr = true;
230 230
    case QGis::WKBMultiPolygon:
231
      count = *(( int* )( wkb + 5 ) );
231
      memcpy( &count, wkb + 5, sizeof( count ) );
232 232
      ptr = wkb + 9;
233 233
      for ( i = 0; i < count; i++ )
234 234
      {
......
301 301
unsigned char* QgsDistanceArea::measureLine( unsigned char* feature, double* area, bool hasZptr )
302 302
{
303 303
  unsigned char *ptr = feature + 5;
304
  unsigned int nPoints = *(( int* )ptr );
304
  unsigned int nPoints;
305
  memcpy( &nPoints, ptr, sizeof( nPoints ) );
305 306
  ptr = feature + 9;
306 307

  
307 308
  QList<QgsPoint> points;
......
311 312
  // Extract the points from the WKB format into the vector
312 313
  for ( unsigned int i = 0; i < nPoints; ++i )
313 314
  {
314
    x = *(( double * ) ptr );
315
    memcpy( &x, ptr, sizeof( x ) );
315 316
    ptr += sizeof( double );
316
    y = *(( double * ) ptr );
317
    memcpy( &y, ptr, sizeof( y ) );
317 318
    ptr += sizeof( double );
318 319
    if ( hasZptr )
319 320
    {
......
398 399
unsigned char* QgsDistanceArea::measurePolygon( unsigned char* feature, double* area, double* perimeter, bool hasZptr )
399 400
{
400 401
  // get number of rings in the polygon
401
  unsigned int numRings = *(( int* )( feature + 1 + sizeof( int ) ) );
402
  unsigned int numRings;
403
  memcpy( &numRings, feature + 1 + sizeof( int ), sizeof( numRings ) );
402 404

  
403 405
  if ( numRings == 0 )
404 406
    return 0;
......
418 420
  {
419 421
    for ( unsigned int idx = 0; idx < numRings; idx++ )
420 422
    {
421
      int nPoints = *(( int* )ptr );
423
      int nPoints;
424
      memcpy( &nPoints, ptr, sizeof( nPoints ) );
422 425
      ptr += 4;
423 426

  
424 427
      // Extract the points from the WKB and store in a pair of
425 428
      // vectors.
426 429
      for ( int jdx = 0; jdx < nPoints; jdx++ )
427 430
      {
428
        x = *(( double * ) ptr );
431
        memcpy( &x, ptr, sizeof( x ) );
429 432
        ptr += sizeof( double );
430
        y = *(( double * ) ptr );
433
        memcpy( &y, ptr, sizeof( y ) );
431 434
        ptr += sizeof( double );
432 435
        if ( hasZptr )
433 436
        {