readline_fix.patch

Eamonn Webster, 10/21/2013 09:36 PM

Download (2.51 KB)

View differences:

ChangeLog
1
Mon Oct 21 21:19:34 2013  Eamonn Webster  <eamonn.webster@gmail.com>
2

  
3
	* ext/readline/readline.c: Always close the file as we dup'ed the descriptor
4

  
5
	* test/readline/test_readline.rb: Assign a 10,000 times shouldn't run out of handles
6

  
1 7
Fri Oct 18 15:23:34 2013  Koichi Sasada  <ko1@atdot.net>
2 8

  
3 9
	* gc.c: change terminology of heap.
ext/readline/readline.c
456 456
static void
457 457
clear_rl_instream(void)
458 458
{
459
    rb_io_t *ifp;
460 459
    if (rl_instream) {
461 460
        if (readline_instream) {
462
            rb_io_check_initialized(ifp = RFILE(rb_io_taint_check(readline_instream))->fptr);
463
            if (ifp->fd < 0 || fileno(rl_instream) == ifp->fd) {
464
                fclose(rl_instream);
465
                rl_instream = NULL;
466
            }
461
            fclose(rl_instream);
467 462
        }
468 463
        readline_instream = Qfalse;
469 464
        rl_instream = NULL;
......
510 505
static void
511 506
clear_rl_outstream(void)
512 507
{
513
    rb_io_t *ofp;
514 508
    if (rl_outstream) {
515 509
        if (readline_outstream) {
516
            rb_io_check_initialized(ofp = RFILE(rb_io_taint_check(readline_outstream))->fptr);
517
            if (ofp->fd < 0 || fileno(rl_outstream) == ofp->fd) {
518
                fclose(rl_outstream);
519
                rl_outstream = NULL;
520
            }
510
            fclose(rl_outstream);
521 511
        }
522 512
        readline_outstream = Qfalse;
523 513
        rl_outstream = NULL;
test/readline/test_readline.rb
295 295
    end
296 296
  end
297 297

  
298
  def test_close_streams
299
    assert_equal(10000, 10000.times{ Readline.input = STDIN })
300
  end
301

  
298 302
  def test_closed_outstream
299 303
    bug5803 = '[ruby-dev:45043]'
300 304
    IO.pipe do |r, w|
301
-