This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
libstdc++/10094: Regression: wfilebuf::showmanyc return value too high.
- From: peturr02 at ru dot is
- To: gcc-gnats at gcc dot gnu dot org
- Date: 15 Mar 2003 10:36:06 -0000
- Subject: libstdc++/10094: Regression: wfilebuf::showmanyc return value too high.
- Reply-to: peturr02 at ru dot is
>Number: 10094
>Category: libstdc++
>Synopsis: Regression: wfilebuf::showmanyc return value too high.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Mar 15 10:46:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: peturr02 at ru dot is
>Release: gcc mainline from 20030312
>Organization:
>Environment:
Red Hat Linux 8.0
>Description:
The return value of wfilebuf::showmanyc is only calculated from codecvt::max_length and the number of bytes in the file. This means that when the file contains illegal multibyte sequences, showmanyc promises more characters than underflow can deliver.
>How-To-Repeat:
See attachment.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="showmanycbug2.cc"
Content-Disposition: inline; filename="showmanycbug2.cc"
#include <fstream>
#include <locale>
#undef NDEBUG
#include <cassert>
int main()
{
using namespace std;
const char* name = "tmp";
const char* strlit = "\xc0\xff For What You Dream Of";
filebuf fbout;
fbout.open(name, ios_base::out | ios_base::trunc);
for (int i = 0; i < BUFSIZ; ++i)
fbout.sputc('a');
fbout.sputn(strlit, strlen(strlit));
fbout.close();
wfilebuf fbin;
fbin.pubimbue(locale("se_NO.UTF-8"));
fbin.open(name, ios_base::in);
streamsize n = fbin.in_avail();
while (n > 0)
{
if (--n == 0)
n = fbin.in_avail();
wfilebuf::int_type c = fbin.sbumpc();
assert(c != wfilebuf::traits_type::eof());
}
fbin.close();
return 0;
}