Skip to content

Commit 6b86656

Browse files
committed
Fix "instance variable @options not initialized" warning
1 parent f4bd88b commit 6b86656

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
* Fix `warning: instance variable @options not initialized` when
4+
running under verbose mode (`-w`, `$VERBOSE = true`).
5+
36
* Fix SmartyPants single quotes right after a link. For example:
47

58
~~~markdown

ext/redcarpet/rc_render.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ static VALUE rb_redcarpet_rbase_alloc(VALUE klass)
390390
static void rb_redcarpet__overload(VALUE self, VALUE base_class)
391391
{
392392
struct rb_redcarpet_rndr *rndr;
393+
VALUE options_ivar;
393394

394395
Data_Get_Struct(self, struct rb_redcarpet_rndr, rndr);
395396
rndr->options.self = self;
@@ -411,7 +412,8 @@ static void rb_redcarpet__overload(VALUE self, VALUE base_class)
411412
}
412413
}
413414

414-
if (rb_iv_get(self, "@options") == Qnil)
415+
options_ivar = rb_attr_get(self, rb_intern("@options"));
416+
if (options_ivar == Qundef || options_ivar == Qnil)
415417
rb_iv_set(self, "@options", rb_hash_new());
416418
}
417419

0 commit comments

Comments
 (0)