From d704b2515d5f8ba2d86c19a7107f9a50fb7674c8 Mon Sep 17 00:00:00 2001 From: Kevin Ryde Date: Fri, 9 Jul 2004 23:34:55 +0000 Subject: [PATCH] (scm_make_regexp): Free rx on error, to avoid memory leak. --- libguile/regex-posix.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libguile/regex-posix.c b/libguile/regex-posix.c index 26b49f5d0..63278de86 100644 --- a/libguile/regex-posix.c +++ b/libguile/regex-posix.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2004 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -210,9 +210,12 @@ SCM_DEFINE (scm_make_regexp, "make-regexp", 1, 0, 1, cflags & ~REG_NOSUB); if (status != 0) { + char *errmsg = scm_regexp_error_msg (status, rx); + free (rx); + scm_done_free (sizeof (regex_t)); scm_error (scm_regexp_error_key, FUNC_NAME, - scm_regexp_error_msg (status, rx), + errmsg, SCM_BOOL_F, SCM_BOOL_F); /* never returns */