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
parent 657d9d5149
commit 69310d40ae
1 changed files with 1 additions and 1 deletions

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) ->