Ticket #6827: restrict_impl.patch

File restrict_impl.patch, 941 bytes (added by msuvajac@…, 10 years ago)

Patch for the bug.

  • boost\iostreams\detail\restrict_impl.hpp

     
    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        if (end_ != -1 && end_ <= std::numeric_limits<std::streamsize>::max())
     150            amt = (std::min) (n, static_cast<std::streamsize>(end_ - pos_));
     151
    151152        std::streamsize result =
    152153            iostreams::read(this->component(), src, s, amt);
    153154        if (result != -1)
    154155            pos_ += result;
    155156        return result;
    156157    }