[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: 23-gary-dmalloc-found-some-bugs.patch
From: |
Gary V. Vaughan |
Subject: |
FYI: 23-gary-dmalloc-found-some-bugs.patch |
Date: |
Fri, 21 Sep 2001 04:34:02 +0100 |
User-agent: |
Mutt/1.3.22.1i |
Index: ChangeLog
from Gary V. Vaughan <address@hidden>
* libltdl/ltdl.c: Added support for dmalloc, and uncovered some
memory bugs as a result.
Index: libltdl/ltdl.c
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/ltdl.c,v
retrieving revision 1.157
diff -u -p -u -r1.157 ltdl.c
--- libltdl/ltdl.c 2001/09/13 19:43:58 1.157
+++ libltdl/ltdl.c 2001/09/21 03:26:34
@@ -94,6 +94,10 @@ Foundation, Inc., 59 Temple Place, Suite
#include "ltdl.h"
+#if WITH_DMALLOC
+# include <dmalloc.h>
+#endif
+
@@ -166,6 +170,18 @@ LT_GLOBAL_DATA void (*lt_dlfree) LT_PA
/* The following macros reduce the amount of typing needed to cast
assigned memory. */
+#if WITH_DMALLOC
+
+#define LT_DLMALLOC(tp, n) ((tp *) xmalloc ((n) * sizeof(tp)))
+#define LT_DLREALLOC(tp, p, n) ((tp *) xrealloc ((p), (n) * sizeof(tp)))
+#define LT_DLFREE(p) \
+ LT_STMT_START { if (p) (p) = (xfree (p), (lt_ptr) 0); } LT_STMT_END
+
+#define LT_EMALLOC(tp, n) ((tp *) xmalloc ((n) * sizeof(tp)))
+#define LT_EREALLOC(tp, p, n) ((tp *) xrealloc ((p), (n) * sizeof(tp)))
+
+#else
+
#define LT_DLMALLOC(tp, n) ((tp *) lt_dlmalloc ((n) * sizeof(tp)))
#define LT_DLREALLOC(tp, p, n) ((tp *) rpl_realloc ((p), (n) * sizeof(tp)))
#define LT_DLFREE(p) \
@@ -174,8 +190,10 @@ LT_GLOBAL_DATA void (*lt_dlfree) LT_PA
#define LT_EMALLOC(tp, n) ((tp *) lt_emalloc ((n) * sizeof(tp)))
#define LT_EREALLOC(tp, p, n) ((tp *) lt_erealloc ((p), (n) * sizeof(tp)))
+#endif
+
#define LT_DLMEM_REASSIGN(p, q) LT_STMT_START { \
- if ((p) != (q)) { lt_dlfree (p); (p) = (q); (q) = 0; } \
+ if ((p) != (q)) { if (p) lt_dlfree (p); (p) = (q); (q) = 0; } \
} LT_STMT_END
@@ -881,10 +899,10 @@ char *
lt_estrdup (str)
const char *str;
{
- char *dup = strdup (str);
- if (LT_STRLEN (str) && !dup)
+ char *copy = strdup (str);
+ if (LT_STRLEN (str) && !copy)
LT_DLMUTEX_SETERROR (LT_DLSTRERROR (NO_MEMORY));
- return dup;
+ return copy;
}
@@ -1685,9 +1703,17 @@ static int lt_argz_insert LT_PARAM
static int lt_argz_insertinorder LT_PARAMS((char **pargz,
size_t *pargz_len,
const char *entry));
+static int lt_argz_insertdir LT_PARAMS((char **pargz,
+ size_t *pargz_len,
+ const char *dirnam,
+ struct dirent *dp));
static int lt_dlpath_insertdir LT_PARAMS((char **ppath,
char *before,
const char *dir));
+static int list_files_by_dir LT_PARAMS((const char *dirnam,
+ char **pargz,
+ size_t *pargz_len));
+static int file_not_found LT_PARAMS((void));
static char *user_search_path= 0;
static lt_dlloader *loaders = 0;
@@ -2139,10 +2165,10 @@ foreach_dirinpath (search_path, base_nam
int result = 0;
int filenamesize = 0;
int lenbase = LT_STRLEN (base_name);
- size_t argz_len = 0;
- char * argz = 0;
- char * filename = 0;
- char * canonical = 0;
+ int argz_len = 0;
+ char *argz = 0;
+ char *filename = 0;
+ char *canonical = 0;
LT_DLMUTEX_LOCK ();
@@ -2923,7 +2949,6 @@ lt_dlopenext (filename)
char * ext = 0;
int len;
int errors = 0;
- int file_found = 1; /* until proven otherwise */
if (!filename)
{
@@ -3284,6 +3309,9 @@ lt_dlclose (handle)
errors += handle->loader->module_close (data, handle->module);
errors += unload_deplibs(handle);
+
+ /* It is up to the callers to free the data itself. */
+ LT_DLFREE (handle->caller_data);
LT_DLFREE (handle->info.filename);
LT_DLFREE (handle->info.name);
--
())_. Gary V. Vaughan gary@(oranda.demon.co.uk|gnu.org)
( '/ Research Scientist http://www.oranda.demon.co.uk ,_())____
/ )= GNU Hacker http://www.gnu.org/software/libtool \' `&
`(_~)_ Tech' Author http://sources.redhat.com/autobook =`---d__/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: 23-gary-dmalloc-found-some-bugs.patch,
Gary V. Vaughan <=