Skip to content

Commit

Permalink
Fix memory leak in setupterm
Browse files Browse the repository at this point in the history
The allocated Fiddle::Pointer never gets freed because it doesn't have a
free function defined for when it gets garbage collected. This commit
changes it to use the default free function.
  • Loading branch information
peterzhu2118 committed Jul 29, 2024
1 parent c0469a1 commit d3cca3f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/reline/terminfo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ module Reline::Terminfo
end

def self.setupterm(term, fildes)
errret_int = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT)
errret_int = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT, Fiddle::RUBY_FREE)
ret = @setupterm.(term, fildes, errret_int)
case ret
when 0 # OK
Expand Down

0 comments on commit d3cca3f

Please sign in to comment.