[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
readlink, getcwd memory leaks
From: |
Kevin Ryde |
Subject: |
readlink, getcwd memory leaks |
Date: |
Fri, 26 Mar 2004 06:12:16 +1000 |
User-agent: |
Gnus/5.110002 (No Gnus v0.2) Emacs/21.3 (gnu/linux) |
* 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.
--- 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;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- readlink, getcwd memory leaks,
Kevin Ryde <=