diff options
author | Undecidable Robot <undecidabot@gmail.com> | 2016-05-21 23:34:05 +0800 |
---|---|---|
committer | Undecidable Robot <undecidabot@gmail.com> | 2016-05-21 23:44:25 +0800 |
commit | 4e23e2d65e013077d200e85dbd85326909515bf6 (patch) | |
tree | b9399751b92a174eccb66e762f1986c85e0b020e | |
parent | ab8dc946fbc12e0b7e96cf5f2c1064c8c43b6ede (diff) | |
download | lpeglabel-4e23e2d65e013077d200e85dbd85326909515bf6.tar.gz lpeglabel-4e23e2d65e013077d200e85dbd85326909515bf6.tar.bz2 lpeglabel-4e23e2d65e013077d200e85dbd85326909515bf6.zip |
Fixing minor memory leak in error reporting
-rw-r--r-- | relabel.lua | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/relabel.lua b/relabel.lua index f849b58..5fa0db6 100644 --- a/relabel.lua +++ b/relabel.lua | |||
@@ -80,7 +80,7 @@ for i, err in ipairs(errinfo) do | |||
80 | labels[err[1]] = i | 80 | labels[err[1]] = i |
81 | end | 81 | end |
82 | 82 | ||
83 | local errfound | 83 | local errfound = {} |
84 | 84 | ||
85 | local function expect(pattern, labelname) | 85 | local function expect(pattern, labelname) |
86 | local label = labels[labelname] | 86 | local label = labels[labelname] |
@@ -328,7 +328,6 @@ end | |||
328 | local function compile (p, defs) | 328 | local function compile (p, defs) |
329 | if mm.type(p) == "pattern" then return p end -- already compiled | 329 | if mm.type(p) == "pattern" then return p end -- already compiled |
330 | p = p .. " " -- for better reporting of column numbers in errors when at EOF | 330 | p = p .. " " -- for better reporting of column numbers in errors when at EOF |
331 | errfound = {} | ||
332 | local cp, label, suffix = pattern:match(p, 1, defs) | 331 | local cp, label, suffix = pattern:match(p, 1, defs) |
333 | if #errfound > 0 then | 332 | if #errfound > 0 then |
334 | local lines = {} | 333 | local lines = {} |
@@ -344,6 +343,7 @@ local function compile (p, defs) | |||
344 | tinsert(errors, rep(" ", col-1) .. "^") | 343 | tinsert(errors, rep(" ", col-1) .. "^") |
345 | end | 344 | end |
346 | end | 345 | end |
346 | errfound = {} | ||
347 | error(concat(errors, "\n")) | 347 | error(concat(errors, "\n")) |
348 | end | 348 | end |
349 | return cp | 349 | return cp |