[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Segfault in save_bash_input. Array index is out of a range.
From: |
Chet Ramey |
Subject: |
Re: Segfault in save_bash_input. Array index is out of a range. |
Date: |
Thu, 23 Jul 2015 16:18:15 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 |
On 7/22/15 5:00 PM, Alexey Makhalov wrote:
> I have met situation when nfd(returned by fcntl) is 217, but nbuffers is
> only 25
>
> if (buffers[nfd])
> {
> /* What's this? A stray buffer without an associated open file
> descriptor? Free up the buffer and report the error. */
> internal_error (_("save_bash_input: buffer already exists for new fd
> %d"), nfd);
> free_buffered_stream (buffers[nfd]);
> }
> and free_buffered_stream() causes a segfault.
Thanks, this is a good fix.
> I added extra comparison nfd < nbuffers - it works for me.
> Why do we need this check? Does stray buffer happen, when nfd is in a range
> [0,nbuffers)?
I forget the exact reason, but I'm sure I ran into that situation in the
past. It's more robust programming, at least.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/