~ubuntu-branches/debian/sid/gdal/sid

« back to all changes in this revision

Viewing changes to frmts/iso8211/ddfrecord.cpp

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2012-05-07 15:04:42 UTC
  • mfrom: (5.5.16 experimental)
  • Revision ID: package-import@ubuntu.com-20120507150442-2eks97loeh6rq005
Tags: 1.9.0-1
* Ready for sid, starting transition.
* All symfiles updated to latest builds.
* Added dh_numpy call in debian/rules to depend on numpy ABI.
* Policy bumped to 3.9.3, no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
 
 * $Id: ddfrecord.cpp 16282 2009-02-09 20:41:42Z warmerdam $
 
2
 * $Id: ddfrecord.cpp 23598 2011-12-18 23:40:29Z rouault $
3
3
 *
4
4
 * Project:  ISO 8211 Access
5
5
 * Purpose:  Implements the DDFRecord class.
30
30
#include "iso8211.h"
31
31
#include "cpl_conv.h"
32
32
 
33
 
CPL_CVSID("$Id: ddfrecord.cpp 16282 2009-02-09 20:41:42Z warmerdam $");
 
33
CPL_CVSID("$Id: ddfrecord.cpp 23598 2011-12-18 23:40:29Z rouault $");
34
34
 
35
 
static const size_t nLeaderSize = 24;
 
35
static const int nLeaderSize = 24;
36
36
 
37
37
/************************************************************************/
38
38
/*                             DDFRecord()                              */
409
409
                return FALSE;
410
410
            }
411
411
 
 
412
            if (_fieldAreaStart + nFieldPos - nLeaderSize < 0 ||
 
413
                nDataSize - (_fieldAreaStart + nFieldPos - nLeaderSize) < nFieldLength)
 
414
            {
 
415
                CPLError( CE_Failure, CPLE_AppDefined,
 
416
                          "Not enough byte to initialize field `%s'.",
 
417
                          szTag );
 
418
                return FALSE;
 
419
            }
 
420
 
412
421
/* -------------------------------------------------------------------- */
413
422
/*      Assign info the DDFField.                                       */
414
423
/* -------------------------------------------------------------------- */
444
453
        int nFieldEntryWidth = _sizeFieldLength + _sizeFieldPos + _sizeFieldTag;
445
454
        nFieldCount = 0;
446
455
        int i=0;
 
456
 
 
457
        if (nFieldEntryWidth == 0)
 
458
        {
 
459
            CPLError( CE_Failure, CPLE_OutOfMemory,
 
460
                      "Invalid record buffer size : %d.",
 
461
                      nFieldEntryWidth );
 
462
            return FALSE;
 
463
        }
 
464
        
447
465
        char *tmpBuf = (char*)VSIMalloc(nFieldEntryWidth);
448
466
 
449
467
        if( tmpBuf == NULL )
485
503
        // Now, rewind a little.  Only the TERMINATOR should have been read
486
504
        // --------------------------------------------------------------------
487
505
        int rewindSize = nFieldEntryWidth - 1;
488
 
        FILE *fp = poModule->GetFP();
 
506
        VSILFILE *fp = poModule->GetFP();
489
507
        vsi_l_offset pos = VSIFTellL(fp) - rewindSize;
490
508
        VSIFSeekL(fp, pos, SEEK_SET);
491
509
        nDataSize -= rewindSize;
553
571
                return FALSE;
554
572
            }
555
573
 
 
574
            if (_fieldAreaStart + nFieldPos - nLeaderSize < 0 ||
 
575
                nDataSize - (_fieldAreaStart + nFieldPos - nLeaderSize) < nFieldLength)
 
576
            {
 
577
                CPLError( CE_Failure, CPLE_AppDefined,
 
578
                          "Not enough byte to initialize field `%s'.",
 
579
                          szTag );
 
580
                return FALSE;
 
581
            }
 
582
 
556
583
            /* ------------------------------------------------------------- */
557
584
            /* Assign info the DDFField.                                     */
558
585
            /* ------------------------------------------------------------- */