Skip to content

Commit

Permalink
Avoid potential crashes due to key data getting GC'd
Browse files Browse the repository at this point in the history
  • Loading branch information
mpalmer committed Oct 7, 2022
1 parent 358379c commit a032392
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ruby/lib/enquo/root.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ def self.new(key)
_new_from_static_root_key(key)
else
raise ArgumentError, "key must be a root key provider object (got a #{key.class})"
end.tap do |k|
# DIRTY HACK ALERT: take a reference to the key so it doesn't get GC'd
# If someone can come up with a better way to acheive this, I'm all ears
k.instance_variable_set(:@_key, key)
end
end

Expand Down

0 comments on commit a032392

Please sign in to comment.