This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Free errstring if _dl_addr returns 0
On Fri, Sep 7, 2012 at 1:24 PM, Roland McGrath <roland@hack.frob.com> wrote:
> It needs comments. You can just extend the comment at the top of that
> block. While you're at it, fix the typo there ("namespave").
>
> I don't see any way that _dl_addr return nonzero without setting MAP to
> non-null, so that test can be removed.
>
>
> Thanks,
> Roland
Here is the new patch. OK to install?
Thanks.
--
H.J.
-- * dlfcn/dlerror.c (check_free): Free errstring if _dl_addr
returns 0. Don't check if map is NULL.
diff --git a/dlfcn/dlerror.c b/dlfcn/dlerror.c
index 8138cc2..7d3b3f8 100644
--- a/dlfcn/dlerror.c
+++ b/dlfcn/dlerror.c
@@ -190,11 +190,13 @@ 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. _dl_addr retuns 0
+ when check_free isn't called from any loaded object. This
+ indicates static executable and we can free the string. */
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)
free ((char *) rec->errstring);
}
}
-