withXXX functions do not free memory if action throws exception
rethab opened this issue · 2 comments
rethab commented
All the 'withXXX' do not free the previously allocated memory if the action throws an exception.
dmp1ce commented
@rethab Did you have a way to reproduce this? How did you determine that there is a memory leak?
rethab commented
Take a look at this:
withCtx homedir localeStr prot f = do
ctx <- newCtx homedir localeStr prot
res <- f ctx
freeCtx ctx
return res
Now f
is a user - supplied function. If that function throws an exception, then freeCtx
is never run.