From 954f6d89db60886390e7b76fb79029b9f1ca7e68 Mon Sep 17 00:00:00 2001 From: simonmar Date: Fri, 25 Jul 2003 10:03:51 +0000 Subject: [PATCH] [project @ 2003-07-25 10:03:51 by simonmar] regcomp: don't attach the regfree finalizer if c_regcomp failed. --- Text/Regex/Posix.hsc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 -- ----------------------------------------------------------------------------- -- 1.7.10.4