Project

General

Profile

Actions

Backport #6487

closed

io_strip_bom does not take in to account short files

Added by tenderlovemaking (Aaron Patterson) almost 12 years ago. Updated almost 12 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
Actions #1

Updated by nobu (Nobuyoshi Nakada) almost 12 years ago

  • 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

Actions #2

Updated by nobu (Nobuyoshi Nakada) almost 12 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby master to Backport193
Actions #3

Updated by nobu (Nobuyoshi Nakada) almost 12 years ago

  • Status changed from Closed to Open
Actions #4

Updated by naruse (Yui NARUSE) almost 12 years ago

  • 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: Atom PDF

Like0
Like0Like0Like0Like0