Project

General

Profile

Backport #6487

io_strip_bom does not take in to account short files

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

Status:
Closed
Priority:
Normal
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

Associated revisions

Revision 3cc5ddca
Added by nobu (Nobuyoshi Nakada) over 7 years ago

Bug #6487

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 35766
Added by nobu (Nobuyoshi Nakada) over 7 years ago

Bug #6487

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

Revision 35766
Added by nobu (Nobuyoshi Nakada) over 7 years ago

Bug #6487

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

Revision 35766
Added by nobu (Nobuyoshi Nakada) over 7 years ago

Bug #6487

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

Revision 35766
Added by nobu (Nobuyoshi Nakada) over 7 years ago

Bug #6487

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

Revision 35766
Added by nobu (Nobuyoshi Nakada) over 7 years ago

Bug #6487

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

Revision 35766
Added by nobu (Nobuyoshi Nakada) over 7 years ago

Bug #6487

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

Revision cb1a7935
Added by naruse (Yui NARUSE) over 7 years ago

merge revision(s) 35766:

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@35782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 35782
Added by naruse (Yui NARUSE) over 7 years ago

merge revision(s) 35766:

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

History

#1

Updated by nobu (Nobuyoshi Nakada) over 7 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

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

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

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

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

  • Status changed from Closed to Open
#4

Updated by naruse (Yui NARUSE) over 7 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]

Also available in: Atom PDF