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:
parent
3782b906d7
commit
42552e5efb
1 changed files with 1 additions and 1 deletions
|
@ -39,7 +39,7 @@ search = (re, str, start) ->
|
||||||
res = regex.search re, str, str\len(), start
|
res = regex.search re, str, str\len(), start
|
||||||
return unless res != nil
|
return unless res != nil
|
||||||
first, last = res[0], res[1]
|
first, last = res[0], res[1]
|
||||||
ffi.C.free res
|
ffi.gc(res, ffi.C.free)
|
||||||
first, last
|
first, last
|
||||||
|
|
||||||
replace = (re, replacement, str, max_count) ->
|
replace = (re, replacement, str, max_count) ->
|
||||||
|
|
Loading…
Reference in a new issue