From: simonmar Date: Fri, 25 Jul 2003 10:03:51 +0000 (+0000) Subject: [project @ 2003-07-25 10:03:51 by simonmar] X-Git-Tag: nhc98-1-18-release~571 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=954f6d89db60886390e7b76fb79029b9f1ca7e68;p=haskell-directory.git [project @ 2003-07-25 10:03:51 by simonmar] regcomp: don't attach the regfree finalizer if c_regcomp failed. --- diff --git a/Text/Regex/Posix.hsc b/Text/Regex/Posix.hsc index 9cc06f7..1937884 100644 --- a/Text/Regex/Posix.hsc +++ b/Text/Regex/Posix.hsc @@ -60,9 +60,9 @@ regcomp pattern flags = do r <- withCString pattern $ \cstr -> withForeignPtr regex_fptr $ \p -> c_regcomp p cstr (fromIntegral flags) - addForeignPtrFinalizer regex_fptr ptr_regfree if (r == 0) - then return (Regex regex_fptr) + then do addForeignPtrFinalizer regex_fptr ptr_regfree + return (Regex regex_fptr) else error "Text.Regex.Posix.regcomp: error in pattern" -- ToDo -- -----------------------------------------------------------------------------