unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Kevin Ryde <user42@zip.com.au>
Subject: readlink, getcwd memory leaks
Date: Fri, 26 Mar 2004 06:12:16 +1000	[thread overview]
Message-ID: <877jx8hejj.fsf@zip.com.au> (raw)

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

        * filesys.c (scm_getcwd, scm_readlink): Avoid memory leak on errors.

Unbounded growth can be seen with

	(while #t (false-if-exception (readlink "nosuchfile")))

and

	(mkdir "somedir")
	(chdir "somedir")
	(rmdir "../somedir")
	(while #t (false-if-exception (getcwd)))

This will be for the 1.6 branch too I think.


[-- Attachment #2: filesys.c.leak.diff --]
[-- Type: text/plain, Size: 999 bytes --]

--- filesys.c.~1.119.~	2003-05-30 08:40:07.000000000 +1000
+++ filesys.c	2004-03-25 14:16:28.000000000 +1000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996,1997,1998,1999,2000,2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996,1997,1998,1999,2000,2001, 2002, 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
@@ -929,7 +929,12 @@
       wd = scm_malloc (size);
     }
   if (rv == 0)
-    SCM_SYSERROR;
+    {
+      int save_errno = errno;
+      free (wd);
+      errno = save_errno;
+      SCM_SYSERROR;
+    }
   result = scm_mem2string (wd, strlen (wd));
   free (wd);
   return result;
@@ -1349,7 +1354,12 @@
       buf = scm_malloc (size);
     }
   if (rv == -1)
-    SCM_SYSERROR;
+    {
+      int save_errno = errno;
+      free (buf);
+      errno = save_errno;
+      SCM_SYSERROR;
+    }
   result = scm_mem2string (buf, rv);
   free (buf);
   return result;

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

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

             reply	other threads:[~2004-03-25 20:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-25 20:12 Kevin Ryde [this message]
2004-04-24 22:19 ` readlink, getcwd memory leaks Marius Vollmer
2004-04-24 22:51   ` Kevin Ryde
2004-04-24 23:42     ` Marius Vollmer
2004-04-25  8:16       ` Dirk Herrmann
2004-04-25 18:38         ` Rob Browning
2004-04-26 19:08           ` Marius Vollmer
2004-04-29 21:14             ` Stephen Compall
2004-04-28  0:24       ` Kevin Ryde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877jx8hejj.fsf@zip.com.au \
    --to=user42@zip.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).