about summary refs log tree commit diff
path: root/elf/dl-object.c
diff options
context:
space:
mode:
Diffstat (limited to 'elf/dl-object.c')
-rw-r--r--elf/dl-object.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/elf/dl-object.c b/elf/dl-object.c
index 65e90d66a0..bfd4f2d8c4 100644
--- a/elf/dl-object.c
+++ b/elf/dl-object.c
@@ -40,15 +40,17 @@ _dl_new_object (char *realname, const char *libname, int type,
   struct link_map *new;
   struct libname_list *newname;
 
-  new = (struct link_map *) calloc (sizeof *new, 1);
-  newname = (struct libname_list *) malloc (sizeof *newname + libname_len);
-  if (new == NULL || newname == NULL)
+  new = (struct link_map *) calloc (sizeof (*new) + sizeof (*newname)
+				    + libname_len, 1);
+  if (new == NULL)
     return NULL;
 
-  new->l_name = realname;
+  newname = (struct libname_list *) (new + 1);
   newname->name = (char *) memcpy (newname + 1, libname, libname_len);
   newname->next = NULL;
-  newname->dont_free = 0;
+  newname->dont_free = 1;
+
+  new->l_name = realname;
   new->l_libname = newname;
   new->l_type = type;
   new->l_loader = loader;