delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/12/29/17:33:35

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f
Date: Sat, 29 Dec 2001 17:32:02 -0500
From: AAganichev AT netscape DOT net (Alexander Aganichev)
To: djgpp-workers AT delorie DOT com
Subject: Memory leaks fixes
Message-ID: <319B464B.652FB9D9.09ACFA57@netscape.net>
X-Mailer: Atlas Mailer 1.0
Reply-To: djgpp-workers AT delorie DOT com

---------31b042f36544b68131b042f36544b681
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Content-Disposition: inline

Hi!

I've made two fixes for memory leaks in glob and fsext. I almost sure that no one cares about these leaks since they are almost impossible, but... :-)

-- 
alexander aganichev
url: http://aaganichev.narod.ru



__________________________________________________________________
Your favorite stores, helpful shopping tools and great gift ideas. Experience the convenience of buying online with Shop AT Netscape! http://shopnow.netscape.com/

Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/

---------31b042f36544b68131b042f36544b681
Content-Type: text/plain; charset=iso-8859-1; name="fsext.diff"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline; filename="fsext.diff"
Content-Description: fsext.diff

diff -rup E:\Sources\djgpp\src\libc/fsext/fsext.c libc/fsext/fsext.c
--- E:\Sources\djgpp\src\libc/fsext/fsext.c Thu Jun 29 11:37:10 2000
+++ libc/fsext/fsext.c  Sat Dec 29 14:04:20 2001
@@ -88,11 +88,17 @@ grow_table(int _fd)
 
   if (num_fds <= _fd)
   {
+    __FSEXT_entry *temp;
     int old_fds = num_fds, i;
     num_fds = (_fd+256) & ~255;
-    fsext_list = (__FSEXT_entry *)realloc(fsext_list, num_fds * sizeof(__FSEXT_entry));
-    if (fsext_list == 0)
+    temp = (__FSEXT_entry *)realloc(fsext_list, num_fds * sizeof(__FSEXT_entry));
+    if (temp == 0)
+    {
+      free(fsext_list);
+      fsext_list = NULL;
       return 1;
+    }
+    fsext_list = temp;
     for (i=old_fds; i<num_fds; i++)
     {
       fsext_list[i].function = 0;

---------31b042f36544b68131b042f36544b681
Content-Type: text/plain; charset=iso-8859-1; name="glob.diff"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline; filename="glob.diff"
Content-Description: glob.diff

diff -rup E:\Sources\djgpp\src\libc/posix/glob/glob.c libc/posix/glob/glob.c
--- E:\Sources\djgpp\src\libc/posix/glob/glob.c Wed Oct 17 08:08:40 2001
+++ libc/posix/glob/glob.c  Sat Dec 29 12:55:44 2001
@@ -394,9 +394,14 @@ glob(const char *_pattern, int _flags, i
 
   if (flags & GLOB_APPEND)
   {
-    _pglob->gl_pathv = (char **)realloc(_pglob->gl_pathv, (l_ofs + _pglob->gl_pathc + save_count + 1) * sizeof(char *));
-    if (_pglob->gl_pathv == 0)
+    char **temp = (char **)realloc(_pglob->gl_pathv, (l_ofs + _pglob->gl_pathc + save_count + 1) * sizeof(char *));
+    if (temp == 0)
+    {
+      free(_pglob->gl_pathv);
+      _pglob->gl_pathv = NULL;
       return GLOB_NOSPACE;
+    }
+    _pglob->gl_pathv = temp;
     l_ptr = l_ofs + _pglob->gl_pathc;
   }
   else

---------31b042f36544b68131b042f36544b681--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019