public inbox for java-prs@sourceware.org help / color / mirror / Atom feed
From: "kaloian at doganov dot org" <gcc-bugzilla@gcc.gnu.org> To: java-prs@gcc.gnu.org Subject: [Bug libgcj/30600] gnu.gcj.convert.BytesToCharsetAdaptor calculates bad argument for java.nio.Buffer.limit(int) Date: Sat, 27 Jan 2007 23:14:00 -0000 [thread overview] Message-ID: <20070127231431.10041.qmail@sourceware.org> (raw) In-Reply-To: <bug-30600-14003@http.gcc.gnu.org/bugzilla/> ------- Comment #3 from kaloian at doganov dot org 2007-01-27 23:14 ------- Created an attachment (id=12971) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=12971&action=view) Trivial fix -- `inlenght' is the last valid index of the buffer, so it should be used directly, without adding it to `inpos'. It is stated in BytesToUnicode.read(char[],int,int) java docs: "Note the asymmetry in that the input upper bound is inbuffer[inlength-1], while the output upper bound is outbuffer[outpos+count-1]. The justification is that inlength is like the count field of a BufferedInputStream, while the count parameter is like the length parameter of a read request." But obviously, in BytesToCharsetAdaptor's code `inlength' is not used according to the note above. Instead, it is expected `inlength' to contain a count, which , when added to the value of `inpos', leads to the calculation of a buffer limit greater than buffer's capacity (if `inpos' turns out to be greater than zero). This can be easily avoided by simply using `inlenght' in the way it is expected to be used -- as an absolute index of array, not as a relative element count. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30600
next prev parent reply other threads:[~2007-01-27 23:14 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2007-01-26 17:11 [Bug libgcj/30600] New: " kaloian at doganov dot org 2007-01-26 17:15 ` [Bug libgcj/30600] " kaloian at doganov dot org 2007-01-26 17:18 ` kaloian at doganov dot org 2007-01-27 23:14 ` kaloian at doganov dot org [this message] 2007-01-30 0:05 ` tromey at gcc dot gnu dot org 2007-01-30 2:47 ` tromey at gcc dot gnu dot org 2007-01-30 2:48 ` tromey at gcc dot gnu dot org 2007-01-30 3:06 ` tromey at gcc dot gnu dot org 2007-01-30 3:08 ` tromey at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20070127231431.10041.qmail@sourceware.org \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=java-prs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).