Skip to content

Commit

Permalink
Fix "instance variable @options not initialized" warning
Browse files Browse the repository at this point in the history
  • Loading branch information
kolen committed Mar 7, 2018
1 parent f4bd88b commit 6b86656
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,8 @@
# Changelog

* Fix `warning: instance variable @options not initialized` when
running under verbose mode (`-w`, `$VERBOSE = true`).

* Fix SmartyPants single quotes right after a link. For example:

~~~markdown
Expand Down
4 changes: 3 additions & 1 deletion ext/redcarpet/rc_render.c
Expand Up @@ -390,6 +390,7 @@ static VALUE rb_redcarpet_rbase_alloc(VALUE klass)
static void rb_redcarpet__overload(VALUE self, VALUE base_class)
{
struct rb_redcarpet_rndr *rndr;
VALUE options_ivar;

Data_Get_Struct(self, struct rb_redcarpet_rndr, rndr);
rndr->options.self = self;
Expand All @@ -411,7 +412,8 @@ static void rb_redcarpet__overload(VALUE self, VALUE base_class)
}
}

if (rb_iv_get(self, "@options") == Qnil)
options_ivar = rb_attr_get(self, rb_intern("@options"));
if (options_ivar == Qundef || options_ivar == Qnil)
rb_iv_set(self, "@options", rb_hash_new());
}

Expand Down

0 comments on commit 6b86656

Please sign in to comment.