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 Content-Type: multipart/mixed; boundary=-------31b042f36544b68131b042f36544b681 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; igl_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--