From ce2d0d6e770dbf138ed4fb7649b593412b22122a Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Thu, 29 Oct 2009 13:38:52 -0600 Subject: [PATCH] argp: avoid memory leak argp has been leaking memory since commit 79c0a43, in Jul 2006. * modules/argp (Depends-on): Use dirname-lgpl, not dirname. * lib/argp-namefrob.h (__argp_base_name): Use last_component, not base_name, since the latter malloc()s and can call exit(). Signed-off-by: Eric Blake --- ChangeLog | 6 ++++++ lib/argp-namefrob.h | 4 ++-- modules/argp | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 73d4a061e..47c75be4c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2009-10-29 Eric Blake + argp: avoid memory leak + * modules/argp (Depends-on): Use dirname-lgpl, not dirname. + * lib/argp-namefrob.h (__argp_base_name): Use last_component, not + base_name, since the latter malloc()s and can call exit(). + Leak introduced 2006-07-03. + dirname-lgpl: adjust clients that don't need full dirname * modules/backupfile (Depends-on): Use dirname-lgpl, not dirname. * modules/filenamecat (Depends-on): Likewise. diff --git a/lib/argp-namefrob.h b/lib/argp-namefrob.h index fcb082ad2..7b7b173d3 100644 --- a/lib/argp-namefrob.h +++ b/lib/argp-namefrob.h @@ -1,5 +1,5 @@ /* Name frobnication for compiling argp outside of glibc - Copyright (C) 1997, 2003, 2007 Free Software Foundation, Inc. + Copyright (C) 1997, 2003, 2007, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader . @@ -147,7 +147,7 @@ extern char *__argp_base_name(const char *arg); #else # include "dirname.h" -# define __argp_base_name base_name +# define __argp_base_name last_component #endif #if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME diff --git a/modules/argp b/modules/argp index e772b3e6b..bb1084432 100644 --- a/modules/argp +++ b/modules/argp @@ -24,7 +24,7 @@ m4/argp.m4 Depends-on: alloca -dirname +dirname-lgpl getopt-gnu strchrnul sysexits -- 2.11.0