unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* make-regexp error memory leak
@ 2004-07-04 23:51 Kevin Ryde
  2004-07-07 17:41 ` Rob Browning
  0 siblings, 1 reply; 8+ messages in thread
From: Kevin Ryde @ 2004-07-04 23:51 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 305 bytes --]

When make-regexp throws an error it leaks memory, eg

	(while #t (false-if-exception (make-regexp "[")))

I'm looking at the changes below for the cvs and for 1.6, I think they
get the mallocated counting right.

        * regex-posix.c (scm_make_regexp): Free rx on error, to avoid memory
        leak.


[-- Attachment #2: regex-posix.c.free-cvs.diff --]
[-- Type: text/plain, Size: 648 bytes --]

--- regex-posix.c.~1.62.~	2003-04-07 08:05:25.000000000 +1000
+++ regex-posix.c	2004-07-04 18:56:03.000000000 +1000
@@ -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 library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -188,6 +188,7 @@
 		    cflags & ~REG_NOSUB);
   if (status != 0)
     {
+      scm_gc_free (rx, sizeof(regex_t), "regex");
       scm_error (scm_regexp_error_key,
 		 FUNC_NAME,
 		 scm_regexp_error_msg (status, rx),

[-- Attachment #3: regex-posix.c.free-16.diff --]
[-- Type: text/plain, Size: 677 bytes --]

--- regex-posix.c.~1.53.2.3.~	2002-03-14 15:26:15.000000000 +1000
+++ regex-posix.c	2004-07-04 18:57:30.000000000 +1000
@@ -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,6 +210,8 @@
 		    cflags & ~REG_NOSUB);
   if (status != 0)
     {
+      free (rx);
+      scm_done_free (sizeof (regex_t));
       scm_error (scm_regexp_error_key,
 		 FUNC_NAME,
 		 scm_regexp_error_msg (status, rx),

[-- Attachment #4: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-07-27  1:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-04 23:51 make-regexp error memory leak Kevin Ryde
2004-07-07 17:41 ` Rob Browning
2004-07-08 23:57   ` Kevin Ryde
2004-07-09 18:03     ` Rob Browning
2004-07-10  0:05       ` Kevin Ryde
2004-07-11 18:37         ` Rob Browning
2004-07-23 23:06           ` Kevin Ryde
2004-07-27  1:56             ` Rob Browning

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).