Project

General

Profile

Bug #752 » bug752-exiv2-0.20.patch

Patch for 0.20 (binary compatible) - Andreas Huggel, 31 Jan 2011 19:32

View differences:

trunk/src/tiffcomposite_int.hpp (revision 2435)
1403 1403
        void iniOrigDataBuf();
1404 1404
        //! Update the original data buffer and its size, return true if successful.
1405 1405
        bool updOrigDataBuf(const byte* pData, uint32_t size);
1406
        //! Set a flag to indicate if the array was decoded
1407
        void setDecoded(bool decoded) { decoded_ = decoded; }
1406 1408
        //@}
1407 1409

  
1408 1410
        //! @name Accessors
......
1413 1415
        const ArrayDef* def() const { return arrayDef_; }
1414 1416
        //! Return the number of elements in the definition
1415 1417
        int defSize() const { return defSize_; }
1418
        //! Return the flag which indicates if the array was decoded
1419
        bool decoded() const { return decoded_; }
1416 1420
        //@}
1417 1421

  
1418 1422
    protected:
......
1481 1485
        byte* origData_;            //!< Pointer to the original data buffer (unencrypted)
1482 1486
        uint32_t origSize_;         //!< Size of the original data buffer
1483 1487
        TiffComponent* pRoot_;      //!< Pointer to the root component of the TIFF tree. (Only used for intrusive writing.)
1488
        bool decoded_;              //!< Flag to indicate if the array was decoded
1484 1489
    }; // class TiffBinaryArray
1485 1490

  
1486 1491
    /*!
trunk/src/tiffcomposite.cpp (revision 2435)
143 143
          setSize_(0),
144 144
          origData_(0),
145 145
          origSize_(0),
146
          pRoot_(0)
146
          pRoot_(0),
147
          decoded_(false)
147 148
    {
148 149
        assert(arrayCfg != 0);
149 150
    }
......
162 163
          setSize_(setSize),
163 164
          origData_(0),
164 165
          origSize_(0),
165
          pRoot_(0)
166
          pRoot_(0),
167
          decoded_(false)
166 168
    {
167 169
        // We'll figure out the correct cfg later
168 170
        assert(cfgSelFct != 0);
......
282 284
          setSize_(rhs.setSize_),
283 285
          origData_(rhs.origData_),
284 286
          origSize_(rhs.origSize_),
285
          pRoot_(rhs.pRoot_)
287
          pRoot_(rhs.pRoot_),
288
          decoded_(false)
286 289
    {
287 290
    }
288 291

  
......
841 844
    {
842 845
        TiffComponent* tc = tiffComponent.release();
843 846
        elements_.push_back(tc);
847
        setDecoded(true);
844 848
        return tc;
845 849
    } // TiffBinaryArray::doAddChild
846 850

  
......
1036 1040

  
1037 1041
    uint32_t TiffBinaryArray::doCount() const
1038 1042
    {
1039
        if (cfg() == 0) return TiffEntryBase::doCount();
1043
        if (cfg() == 0 || !decoded()) return TiffEntryBase::doCount();
1040 1044

  
1041 1045
        if (elements_.empty()) return 0;
1042 1046

  
......
1366 1370
                                      uint32_t  dataIdx,
1367 1371
                                      uint32_t& imageIdx)
1368 1372
    {
1369
        if (cfg() == 0) return TiffEntryBase::doWrite(ioWrapper,
1370
                                                      byteOrder,
1371
                                                      offset,
1372
                                                      valueIdx,
1373
                                                      dataIdx,
1374
                                                      imageIdx);
1373
        if (cfg() == 0 || !decoded()) return TiffEntryBase::doWrite(ioWrapper,
1374
                                                                    byteOrder,
1375
                                                                    offset,
1376
                                                                    valueIdx,
1377
                                                                    dataIdx,
1378
                                                                    imageIdx);
1375 1379
        if (cfg()->byteOrder_ != invalidByteOrder) byteOrder = cfg()->byteOrder_;
1376 1380
        // Tags must be sorted in ascending order
1377 1381
        std::sort(elements_.begin(), elements_.end(), cmpTagLt);
......
1681 1685

  
1682 1686
    uint32_t TiffBinaryArray::doSize() const
1683 1687
    {
1684
        if (cfg() == 0) return TiffEntryBase::doSize();
1688
        if (cfg() == 0 || !decoded()) return TiffEntryBase::doSize();
1685 1689

  
1686 1690
        if (elements_.empty()) return 0;
1687 1691

  
trunk/src/tiffvisitor.cpp (revision 2435)
496 496

  
497 497
    void TiffDecoder::visitBinaryArray(TiffBinaryArray* object)
498 498
    {
499
        if (object->cfg() == 0) {
499
        if (object->cfg() == 0 || !object->decoded()) {
500 500
            decodeTiffEntry(object);
501 501
        }
502 502
    }
......
765 765

  
766 766
    } // TiffEncoder::visitIfdMakernoteEnd
767 767

  
768
    void TiffEncoder::visitBinaryArray(TiffBinaryArray* /*object*/)
768
    void TiffEncoder::visitBinaryArray(TiffBinaryArray* object)
769 769
    {
770
        // Nothing to do
770
        if (object->cfg() == 0 || !object->decoded()) {
771
            encodeTiffComponent(object);
772
        }
771 773
    }
772 774

  
773 775
    void TiffEncoder::visitBinaryArrayEnd(TiffBinaryArray* object)
774 776
    {
775 777
        assert(object != 0);
776 778

  
779
        if (object->cfg() == 0 || !object->decoded()) return;
777 780
        int32_t size = object->TiffEntryBase::doSize();
778 781
        if (size == 0) return;
779 782
        if (!object->initialize(pRoot_)) return;
......
1550 1553
            return;
1551 1554
        }
1552 1555

  
1556
        // Check duplicates
1557
        TiffFinder finder(object->tag(), object->group());
1558
        pRoot_->accept(finder);
1559
        TiffEntryBase* te = dynamic_cast<TiffEntryBase*>(finder.result());
1560
        if (te && te->idx() != object->idx()) {
1561
#ifndef SUPPRESS_WARNINGS
1562
            std::cerr << "Not decoding duplicate binary array tag 0x"
1563
                      << std::setw(4) << std::setfill('0') << std::hex
1564
                      << object->tag() << std::dec << ", group "
1565
                      << tiffGroupName(object->group()) << ", idx " << object->idx()
1566
                      << "\n";
1567
#endif
1568
            object->setDecoded(false);
1569
            return;
1570
        }
1571

  
1553 1572
        if (object->TiffEntryBase::doSize() == 0) return;
1554 1573
        if (!object->initialize(pRoot_)) return;
1555

  
1556 1574
        const ArrayCfg* cfg = object->cfg();
1575
        if (cfg == 0) return;
1557 1576

  
1558 1577
        const CryptFct cryptFct = cfg->cryptFct_;
1559 1578
        if (cryptFct != 0) {
(2-2/2)