about summary refs log tree commit diff
path: root/dlfcn/dlerror.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@hack.frob.com>2012-10-09 15:22:16 -0700
committerH.J. Lu <hjl.tools@gmail.com>2012-10-09 15:22:16 -0700
commit273edc5e138caef32a720410c9b2e27613991601 (patch)
tree44e4bcec574f97a7f133c11d7bf4b970f3ac840c /dlfcn/dlerror.c
parentc8450f70fa7e68519d015ba9497f59645ba7ed3a (diff)
downloadglibc-273edc5e138caef32a720410c9b2e27613991601.tar.gz
glibc-273edc5e138caef32a720410c9b2e27613991601.tar.xz
glibc-273edc5e138caef32a720410c9b2e27613991601.zip
Free errstring if _dl_addr doesn't returns 0
Diffstat (limited to 'dlfcn/dlerror.c')
-rw-r--r--dlfcn/dlerror.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/dlfcn/dlerror.c b/dlfcn/dlerror.c
index 8138cc2781..c30b4f1d39 100644
--- a/dlfcn/dlerror.c
+++ b/dlfcn/dlerror.c
@@ -1,5 +1,5 @@
 /* Return error detail for failing <dlfcn.h> functions.
-   Copyright (C) 1995-2000,2002,2003,2004,2005 Free Software Foundation, Inc.
+   Copyright (C) 1995-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -190,11 +190,14 @@ check_free (struct dl_action_result *rec)
     {
       /* We can free the string only if the allocation happened in the
 	 C library used by the dynamic linker.  This means, it is
-	 always the C library in the base namespave.  */
+	 always the C library in the base namespace.  When we're statically
+         linked, the dynamic linker is part of the program and so always
+	 uses the same C library we use here.  */
+#ifdef SHARED
       struct link_map *map = NULL;
       Dl_info info;
-      if (_dl_addr (check_free, &info, &map, NULL) != 0
-	  && map != NULL && map->l_ns == 0)
+      if (_dl_addr (check_free, &info, &map, NULL) != 0 && map->l_ns == 0)
+#endif
 	free ((char *) rec->errstring);
     }
 }