Project

General

Profile

This project is closed and read-only.

Actions

Backport #6487

closed

io_strip_bom does not take in to account short files

Backport #6487: io_strip_bom does not take in to account short files

Added by tenderlovemaking (Aaron Patterson) over 14 years ago. Updated over 14 years ago.

Status:
Closed
Assignee:
-
[ruby-core:45203]

Description

If a file is too short, io_strip_bom will raise an exception because it's trying to convert nil to an integer.

Here is an example:

irb(main):001:0> File.open('foo', 'wb') {}
=> nil
irb(main):002:0> File.new('foo', 'r:bom|utf-8').close
TypeError: no implicit conversion from nil to integer
from (irb):2:in initialize' from (irb):2:in new'
from (irb):2
from /Users/aaron/.local/bin/irb:12:in `

'
irb(main):003:0>

I've attached tests, but I'm not sure the best way to fix. It seems like a pain. :-/


Files

bad_bom.patch (1.44 KB) bad_bom.patch tenderlovemaking (Aaron Patterson), 05/24/2012 10:31 AM

Updated by nobu (Nobuyoshi Nakada) over 14 years ago Actions #1

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r35766.
Aaron, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


Bug #6487

Updated by nobu (Nobuyoshi Nakada) over 14 years ago Actions #2

  • Tracker changed from Bug to Backport
  • Project changed from Ruby to 13

Updated by nobu (Nobuyoshi Nakada) over 14 years ago Actions #3

  • Status changed from Closed to Open

Updated by naruse (Yui NARUSE) over 14 years ago Actions #4

  • Status changed from Open to Closed

This issue was solved with changeset r35782.
Aaron, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 35766:

* io.c (io_strip_bom): check EOF.  [Bug #6487][ruby-core:45203]
Actions

Also available in: PDF Atom