Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unreachable code #162

Closed
marcandre opened this issue Feb 18, 2013 · 1 comment
Closed

Unreachable code #162

marcandre opened this issue Feb 18, 2013 · 1 comment

Comments

@marcandre
Copy link
Contributor

I notice a tiny bug in ext/json/generator/generator.c:514

tmp = rb_convert_type(opts, T_HASH, "Hash", "to_hash");
if (NIL_P(tmp)) tmp = rb_convert_type(opts, T_HASH, "Hash", "to_h");
if (NIL_P(tmp)) {
    rb_raise(rb_eArgError, "opts has to be hash like or convertable into a hash");
}
opts = tmp;

Bug is that rb_convert_type never returns nil.

Either both rb_convert_type are changed to rb_check_convert_type, or these lines are simply replaced by:

opts = rb_convert_type(opts, T_HASH, "Hash", "to_hash");

I'd recommend this last option, for consistency with the rest of MRI.

Also filed as https://bugs.ruby-lang.org/issues/7755

@flori
Copy link
Owner

flori commented Feb 20, 2013

This should be fixed in 22da7f3.

@flori flori closed this as completed Feb 20, 2013
nurse added a commit to ruby/ruby that referenced this issue Nov 20, 2013
  nurse/json@002ac27...e09ffc0
* Remove Rubinius exception since transcoding should be working now.
* Fix flori/json#162 reported by Marc-Andre
  Lafortune <github_rocks@marc-andre.ca>. Thanks!
* Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress
  warning with -Wchar-subscripts and better validate UTF-8 strings.
* Applied patch by ginriki@github to remove unnecessary if.
* Add load/dump interface to JSON::GenericObject to make
  serialize :some_attribute, JSON::GenericObject
  work in Rails active models for convenient
  SomeModel#some_attribute.foo.bar access to serialised JSON data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
mmasaki pushed a commit to mmasaki/ruby that referenced this issue Nov 21, 2013
  nurse/json@002ac27...e09ffc0
* Remove Rubinius exception since transcoding should be working now.
* Fix flori/json#162 reported by Marc-Andre
  Lafortune <github_rocks@marc-andre.ca>. Thanks!
* Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress
  warning with -Wchar-subscripts and better validate UTF-8 strings.
* Applied patch by ginriki@github to remove unnecessary if.
* Add load/dump interface to JSON::GenericObject to make
  serialize :some_attribute, JSON::GenericObject
  work in Rails active models for convenient
  SomeModel#some_attribute.foo.bar access to serialised JSON data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
jperkin pushed a commit to TritonDataCenter/pkgsrc-legacy that referenced this issue Dec 9, 2013
2013-05-13 (1.8.0)
  * Fix flori/json#162 reported by Marc-Andre
    Lafortune <github_rocks@marc-andre.ca>. Thanks!
  * Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress warning with
    -Wchar-subscripts and better validate UTF-8 strings.
  * Applied patch by ginriki@github to remove unnecessary if.
  * Add load/dump interface to JSON::GenericObject to make
        serialize :some_attribute, JSON::GenericObject
    work in Rails active models for convenient SomeModel#some_attribute.foo.bar
    access to serialised JSON data.
jperkin pushed a commit to TritonDataCenter/pkgsrc-legacy that referenced this issue Dec 9, 2013
2013-05-13 (1.8.0)
  * Fix flori/json#162 reported by Marc-Andre
    Lafortune <github_rocks@marc-andre.ca>. Thanks!
  * Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress warning with
    -Wchar-subscripts and better validate UTF-8 strings.
  * Applied patch by ginriki@github to remove unnecessary if.
  * Add load/dump interface to JSON::GenericObject to make
        serialize :some_attribute, JSON::GenericObject
    work in Rails active models for convenient SomeModel#some_attribute.foo.bar
    access to serialised JSON data.
jperkin pushed a commit to TritonDataCenter/pkgsrc-legacy that referenced this issue Jan 21, 2014
2013-05-13 (1.8.0)
  * Fix flori/json#162 reported by Marc-Andre
    Lafortune <github_rocks@marc-andre.ca>. Thanks!
  * Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress warning with
    -Wchar-subscripts and better validate UTF-8 strings.
  * Applied patch by ginriki@github to remove unnecessary if.
  * Add load/dump interface to JSON::GenericObject to make
        serialize :some_attribute, JSON::GenericObject
    work in Rails active models for convenient SomeModel#some_attribute.foo.bar
    access to serialised JSON data.
jperkin pushed a commit to TritonDataCenter/pkgsrc-legacy that referenced this issue Jan 21, 2014
2013-05-13 (1.8.0)
  * Fix flori/json#162 reported by Marc-Andre
    Lafortune <github_rocks@marc-andre.ca>. Thanks!
  * Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress warning with
    -Wchar-subscripts and better validate UTF-8 strings.
  * Applied patch by ginriki@github to remove unnecessary if.
  * Add load/dump interface to JSON::GenericObject to make
        serialize :some_attribute, JSON::GenericObject
    work in Rails active models for convenient SomeModel#some_attribute.foo.bar
    access to serialised JSON data.
tenderlove pushed a commit to tenderlove/ruby that referenced this issue Jan 24, 2014
  nurse/json@002ac27...e09ffc0
* Remove Rubinius exception since transcoding should be working now.
* Fix flori/json#162 reported by Marc-Andre
  Lafortune <github_rocks@marc-andre.ca>. Thanks!
* Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress
  warning with -Wchar-subscripts and better validate UTF-8 strings.
* Applied patch by ginriki@github to remove unnecessary if.
* Add load/dump interface to JSON::GenericObject to make
  serialize :some_attribute, JSON::GenericObject
  work in Rails active models for convenient
  SomeModel#some_attribute.foo.bar access to serialised JSON data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
jperkin pushed a commit to TritonDataCenter/pkgsrc-legacy that referenced this issue Mar 14, 2014
2013-05-13 (1.8.0)
  * Fix flori/json#162 reported by Marc-Andre
    Lafortune <github_rocks@marc-andre.ca>. Thanks!
  * Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress warning with
    -Wchar-subscripts and better validate UTF-8 strings.
  * Applied patch by ginriki@github to remove unnecessary if.
  * Add load/dump interface to JSON::GenericObject to make
        serialize :some_attribute, JSON::GenericObject
    work in Rails active models for convenient SomeModel#some_attribute.foo.bar
    access to serialised JSON data.
jperkin pushed a commit to TritonDataCenter/pkgsrc-legacy that referenced this issue Mar 14, 2014
2013-05-13 (1.8.0)
  * Fix flori/json#162 reported by Marc-Andre
    Lafortune <github_rocks@marc-andre.ca>. Thanks!
  * Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress warning with
    -Wchar-subscripts and better validate UTF-8 strings.
  * Applied patch by ginriki@github to remove unnecessary if.
  * Add load/dump interface to JSON::GenericObject to make
        serialize :some_attribute, JSON::GenericObject
    work in Rails active models for convenient SomeModel#some_attribute.foo.bar
    access to serialised JSON data.
jsonn pushed a commit to jsonn/pkgsrc that referenced this issue Oct 11, 2014
2013-05-13 (1.8.0)
  * Fix flori/json#162 reported by Marc-Andre
    Lafortune <github_rocks@marc-andre.ca>. Thanks!
  * Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress warning with
    -Wchar-subscripts and better validate UTF-8 strings.
  * Applied patch by ginriki@github to remove unnecessary if.
  * Add load/dump interface to JSON::GenericObject to make
        serialize :some_attribute, JSON::GenericObject
    work in Rails active models for convenient SomeModel#some_attribute.foo.bar
    access to serialised JSON data.
jsonn pushed a commit to jsonn/pkgsrc that referenced this issue Oct 11, 2014
2013-05-13 (1.8.0)
  * Fix flori/json#162 reported by Marc-Andre
    Lafortune <github_rocks@marc-andre.ca>. Thanks!
  * Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress warning with
    -Wchar-subscripts and better validate UTF-8 strings.
  * Applied patch by ginriki@github to remove unnecessary if.
  * Add load/dump interface to JSON::GenericObject to make
        serialize :some_attribute, JSON::GenericObject
    work in Rails active models for convenient SomeModel#some_attribute.foo.bar
    access to serialised JSON data.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants