Changeset 830

Show
Ignore:
Timestamp:
08/17/08 00:12:18 (4 months ago)
Author:
hobu
Message:

Fix #68 - incorrect return type for the length of the VLR in the ReadVLR functions

Location:
trunk/src/detail
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/detail/reader10.cpp

    r816 r830  
    224224        read_n(vlrh, m_ifs, sizeof(VLRHeader)); 
    225225 
    226         int16_t count = vlrh.recordLengthAfterHeader; 
     226        uint16_t length = vlrh.recordLengthAfterHeader; 
     227        if (length < 1) { 
     228            throw std::domain_error("VLR record length must be at least 1 byte long"); 
     229        } 
    227230          
    228231        std::vector<uint8_t> data; 
    229         data.resize(count); 
     232        data.resize(length); 
    230233 
    231234        read_n(data.front(), m_ifs, count); 
  • trunk/src/detail/reader11.cpp

    r816 r830  
    311311    uint32_t count = header.GetRecordsCount(); 
    312312    header.SetRecordsCount(0); 
     313     
    313314    for (uint32_t i = 0; i < count; ++i) 
    314315    { 
     316 
    315317        read_n(vlrh, m_ifs, sizeof(VLRHeader)); 
    316  
    317         int16_t count = vlrh.recordLengthAfterHeader; 
     318         
     319 
     320        uint16_t length = vlrh.recordLengthAfterHeader; 
     321         
     322        if (length < 1) { 
     323            throw std::domain_error("VLR record length must be at least 1 byte long"); 
     324        } 
    318325          
    319326        std::vector<uint8_t> data; 
    320         data.resize(count); 
    321  
    322         read_n(data.front(), m_ifs, count); 
    323           
     327        data.resize(length); 
     328 
     329        read_n(data.front(), m_ifs, length); 
     330 
    324331        LASVLR vlr; 
    325332        vlr.SetReserved(vlrh.reserved); 
     
    331338 
    332339        header.AddVLR(vlr); 
    333     } 
    334      
     340 
     341    } 
     342 
    335343    return true; 
    336344}