Opened 16 years ago
Closed 15 years ago
#786 closed Bugs (fixed)
bug in iostreams/copy.hpp line 81
Reported by: | nobody | Owned by: | Jonathan Turkanis |
---|---|---|---|
Milestone: | Component: | iostreams | |
Version: | None | Severity: | Problem |
Keywords: | Cc: |
Description
in boost 1_33_1 iostreams library file copy.hpp line 91 and following... it should rather be : streamsize amt; while ((amt=iostreams::read(src, buf.data(),buffer_size)) != -1) { std::copy(buf.data(), buf.data() + amt, p.first + total); total += amt; } return total; otherwise it happens that the std::copy line is called with amt =-1 which is a bug isnt it ? Regards, Mathieu
Change History (7)
comment:2 by , 15 years ago
There is a patch for this in "official patch format" in: http://article.gmane.org/gmane.comp.lib.boost.user/23522
comment:3 by , 15 years ago
Alexis,
My copy operator did not perform your test and I saw the bug (5 or 6 levels down the stack a copy for last-first would eventually SIGSEGV in memcpy.)
-
Chris DUrso
comment:4 by , 15 years ago
Replying to alexis_wilke:
Mathieu,
Actually, the copy operator will test if(_first < _last) <do the copy> and if amt is -1 that condition will be false. Yet I agree that your way we would avoid one call and one variable ('done' in the original loop). I'm not part of boost so I cannot decide whether to apply the change. But this is only an optimization. Alexis
In VC8 DEBUG mode,it will assert in std::copy because "first > last". It make difficult to debug program.I think it should be repaired necessarily.
comment:6 by , 15 years ago
Component: | None → iostreams |
---|---|
Severity: | → Problem |
comment:7 by , 15 years ago
Resolution: | None → fixed |
---|---|
Status: | assigned → closed |
Fixed in [42294] in branches/iostreams_dev, to be merged into trunk shortly. The fix is a slight modification of the suggestion above.