Skip to content

Commit

Permalink
fixes nim-lang#11139 (re.nim memory leak) (nim-lang#11265)
Browse files Browse the repository at this point in the history
Use the same PCRE function for freeing up the memory as nre.nim does.
  • Loading branch information
narimiran authored and Araq committed May 16, 2019
1 parent 8f198db commit 9d4190a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
1 change: 0 additions & 1 deletion lib/impure/nre.nim
Expand Up @@ -440,7 +440,6 @@ proc extractOptions(pattern: string): tuple[pattern: string, flags: int, study:

proc destroyRegex(pattern: Regex) =
pcre.free_substring(cast[cstring](pattern.pcreObj))
pattern.pcreObj = nil
if pattern.pcreExtra != nil:
pcre.free_study(pattern.pcreExtra)

Expand Down
2 changes: 1 addition & 1 deletion lib/impure/re.nim
Expand Up @@ -65,7 +65,7 @@ proc finalizeRegEx(x: Regex) =
# Fortunately the implementation is unlikely to change.
pcre.free_substring(cast[cstring](x.h))
if not isNil(x.e):
pcre.free_substring(cast[cstring](x.e))
pcre.free_study(x.e)

proc re*(s: string, flags = {reStudy}): Regex =
## Constructor of regular expressions.
Expand Down

0 comments on commit 9d4190a

Please sign in to comment.