summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu.herrb@laas.fr>2006-04-23 13:14:50 +0000
committerMatthieu Herrb <matthieu.herrb@laas.fr>2006-04-23 13:14:50 +0000
commita715634d23fb3124261dbbd8d7d4e6522551bb9b (patch)
tree79161725307b3ae796722dae8caf9cf289ceeb72 /hw
parent79dc6892610c9f8385cde4f0d601cc7481225c16 (diff)
Don't access free memory after unloading a module. Bugzilla #4168.
Diffstat (limited to 'hw')
-rw-r--r--hw/xfree86/dummylib/xalloc.c16
-rw-r--r--hw/xfree86/loader/loader.c4
2 files changed, 19 insertions, 1 deletions
diff --git a/hw/xfree86/dummylib/xalloc.c b/hw/xfree86/dummylib/xalloc.c
index a78250f2b..7131dc5e6 100644
--- a/hw/xfree86/dummylib/xalloc.c
+++ b/hw/xfree86/dummylib/xalloc.c
@@ -94,3 +94,19 @@ Xstrdup(const char *s)
strcpy(sd, s);
return sd;
}
+
+char *
+XNFstrdup(const char *s)
+{
+ char *sd;
+ size_t len;
+
+ if (s == NULL)
+ return NULL;
+
+ len = strlen(s) + 1;
+ sd = (char *)XNFalloc(len);
+ strlcpy(sd, s, len);
+ return sd;
+}
+
diff --git a/hw/xfree86/loader/loader.c b/hw/xfree86/loader/loader.c
index 30f151a4c..4c904128e 100644
--- a/hw/xfree86/loader/loader.c
+++ b/hw/xfree86/loader/loader.c
@@ -818,7 +818,9 @@ static void
AppendSymbol(symlist * list, const char *sym)
{
list->list = xnfrealloc(list->list, (list->num + 1) * sizeof(char **));
- list->list[list->num] = sym;
+ /* copy the symbol, since it comes from a module
+ that can be unloaded later */
+ list->list[list->num] = xnfstrdup(sym);
list->num++;
}