This is an archive of the discontinued LLVM Phabricator instance.

libcxx: Fix for basic_stringbuf::seekoff() after r320604.
ClosedPublic

Authored by pcc on Dec 15 2017, 6:10 PM.

Details

Summary

As a result of this change, the basic_stringbuf constructor that
takes a mode ends up leaving hm_ set to 0, causing the comparison
"
hm_ - str_.data() < noff" in seekoff() to succeed, which caused
the function to incorrectly return -1. The fix is to account for the
possibility of hm_ being 0 when computing the distance from hm_
to the start of the string.

Diff Detail

Repository
rL LLVM

Event Timeline

pcc created this revision.Dec 15 2017, 6:10 PM
mclow.lists added inline comments.Dec 19 2017, 2:49 PM
libcxx/include/sstream
580 ↗(On Diff #127226)

This can be const.

pcc updated this revision to Diff 127609.Dec 19 2017, 3:24 PM
  • Make __hm const
mclow.lists accepted this revision.Dec 19 2017, 3:29 PM

LGTM. I'm going to sprinkle const throughout this file later, but that is a drive-by thing.
All the lines that start out ptrdiff_t __hm = will soon be const ptrdiff_t __hm = ,
but that's not necessary for this bug fix.

This revision is now accepted and ready to land.Dec 19 2017, 3:29 PM
This revision was automatically updated to reflect the committed changes.
pcc marked an inline comment as done.