Correctly handle memory free using Lua GC

Instead of manually free. Otherwise return value of `search' may refer to invalid memory.
Fix Aegisub/Aegisub#99
This commit is contained in:
wangqr 2018-12-09 03:06:21 -05:00 committed by Thomas Goyne
parent 3782b906d7
commit 42552e5efb

View file

@ -39,7 +39,7 @@ search = (re, str, start) ->
res = regex.search re, str, str\len(), start
return unless res != nil
first, last = res[0], res[1]
ffi.C.free res
ffi.gc(res, ffi.C.free)
first, last
replace = (re, replacement, str, max_count) ->