Ticket #6827: restrict_impl2.patch

File restrict_impl2.patch, 1.1 KB (added by msuvajac@…, 10 years ago)

fixed patch

  • M:\boost-dev\boost\iostreams\detail\

    old new  
    141141    template<typename Source>
    142142    std::streamsize read(Source& src, char_type* s, std::streamsize n)
    143143    {
    144144        using namespace std;
    145145        if (!open_)
    146146            open(src, BOOST_IOS::in);
    147         std::streamsize amt =
    148             end_ != -1 ?
    149                 (std::min) (n, static_cast<std::streamsize>(end_ - pos_)) :
    150                 n;
     147
     148        std::streamsize amt(n);
     149
     150        if (end_ != -1)
     151        {
     152            boost::iostreams::stream_offset remaining(end_ - pos_);
     153
     154            if (remaining <= std::numeric_limits<std::streamsize>::max())
     155                amt = (std::min)(n, static_cast<std::streamsize>(remaining));
     156        }
     157
    151158        std::streamsize result =
    152159            iostreams::read(this->component(), src, s, amt);
    153160        if (result != -1)
    154161            pos_ += result;
    155162        return result;
    156163    }