diff --git a/src/regex.cr b/src/regex.cr index 6ed5891fb921..b3ccd7bf0bec 100644 --- a/src/regex.cr +++ b/src/regex.cr @@ -262,7 +262,9 @@ class Regex raise ArgumentError.new("#{String.new(errptr)} at #{erroffset}") if @re.null? @extra = LibPCRE.study(@re, LibPCRE::STUDY_JIT_COMPILE, out studyerrptr) if @extra.null? && studyerrptr - LibPCRE.free.call @re.as(Void*) + {% unless flag?(:interpreted) %} + LibPCRE.free.call @re.as(Void*) + {% end %} raise ArgumentError.new("#{String.new(studyerrptr)}") end LibPCRE.full_info(@re, nil, LibPCRE::INFO_CAPTURECOUNT, out @captures) @@ -270,7 +272,9 @@ class Regex def finalize LibPCRE.free_study @extra - LibPCRE.free.call @re.as(Void*) + {% unless flag?(:interpreted) %} + LibPCRE.free.call @re.as(Void*) + {% end %} end # Determines Regex's source validity. If it is, `nil` is returned. @@ -283,7 +287,9 @@ class Regex def self.error?(source) : String? re = LibPCRE.compile(source, (Options::UTF_8 | Options::NO_UTF8_CHECK | Options::DUPNAMES), out errptr, out erroffset, nil) if re - LibPCRE.free.call re.as(Void*) + {% unless flag?(:interpreted) %} + LibPCRE.free.call re.as(Void*) + {% end %} nil else "#{String.new(errptr)} at #{erroffset}"