Project

General

Profile

Bug #12793

Warning.warn with non-string object

Added by znz (Kazuhiro NISHIYAMA) about 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.0dev (2016-09-27 trunk 56273) [x86_64-linux]
[ruby-core:77430]

Description

Warning.warn with non-string argument causes SEGV.
For example, Warning.warn nil.

Associated revisions

Revision d28bac1c
Added by nobu (Nobuyoshi Nakada) about 3 years ago

error.c: check argument of Warning.warn

  • error.c (rb_warning_s_warn): the argument must be an ASCII-compatible string. [ruby-core:77430] [Bug #12793]

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

Revision 56274
Added by nobu (Nobuyoshi Nakada) about 3 years ago

error.c: check argument of Warning.warn

  • error.c (rb_warning_s_warn): the argument must be an ASCII-compatible string. [ruby-core:77430] [Bug #12793]

Revision 56274
Added by nobu (Nobuyoshi Nakada) about 3 years ago

error.c: check argument of Warning.warn

  • error.c (rb_warning_s_warn): the argument must be an ASCII-compatible string. [ruby-core:77430] [Bug #12793]

Revision 56274
Added by nobu (Nobuyoshi Nakada) about 3 years ago

error.c: check argument of Warning.warn

  • error.c (rb_warning_s_warn): the argument must be an ASCII-compatible string. [ruby-core:77430] [Bug #12793]

Revision 56274
Added by nobu (Nobuyoshi Nakada) about 3 years ago

error.c: check argument of Warning.warn

  • error.c (rb_warning_s_warn): the argument must be an ASCII-compatible string. [ruby-core:77430] [Bug #12793]

History

#1

Updated by nobu (Nobuyoshi Nakada) about 3 years ago

  • Status changed from Open to Closed

Applied in changeset r56274.


error.c: check argument of Warning.warn

  • error.c (rb_warning_s_warn): the argument must be an ASCII-compatible string. [ruby-core:77430] [Bug #12793]

Updated by znz (Kazuhiro NISHIYAMA) about 3 years ago

Kernel#warn accepts nil and 1, but Warning.warn raises TypeError.
Is this difference expected?

% ruby -ve 'warn nil; Warning.warn nil'
ruby 2.4.0dev (2016-09-28 trunk 56281) [x86_64-linux]

-e:1:in `warn': wrong argument type nil (expected String) (TypeError)
        from -e:1:in `<main>'
% ruby -ve 'warn 1; Warning.warn 1'
ruby 2.4.0dev (2016-09-28 trunk 56281) [x86_64-linux]
1
-e:1:in `warn': wrong argument type Integer (expected String) (TypeError)
        from -e:1:in `<main>'

Updated by nobu (Nobuyoshi Nakada) about 3 years ago

While Kernel#warn should be generous since it is a public API,
Warning.warn is a method called by the internal and should be strict.

Also available in: Atom PDF