Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should not return freed pointer #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/fuzzy.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,15 @@ def nysiis(s):
cdef class Soundex:
cdef int size
cdef char *map
cdef char* pout

def __init__(self, size):
self.size = size
self.map = "01230120022455012623010202"
self.pout = <char *>malloc(self.size + 1)

def __del__(self):
free(self.pout)

def __call__(self, s):
cdef char *cs
Expand All @@ -203,7 +208,7 @@ cdef class Soundex:

written = 0

out = <char *>malloc(self.size + 1)
out = self.pout
cs = s
ls = strlen(cs)
for i from 0<= i < ls:
Expand All @@ -224,10 +229,7 @@ cdef class Soundex:
out[i] = 48
out[self.size] = 0

pout = out
free(out)

return pout
return out


cdef extern from "double_metaphone.h":
Expand Down