public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix memory leak in loadarchive.c (BZ #1318)
@ 2005-09-09 16:17 Jakub Jelinek
  2005-09-09 16:59 ` Ulrich Drepper
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2005-09-09 16:17 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Glibc hackers

Hi!

_nl_normalize_codeset returns a freshly malloced string no matter whether
the original string has been already normalized or not.  So we should free
it always, not only when it has not been normalized before.
$ LC_ALL=en_US.UTF-8 valgrind /bin/echo 2>&1 | grep definitely
$ LC_ALL=en_US.utf8 valgrind /bin/echo 2>&1 | grep definitely
==28320==    definitely lost: 5 bytes in 1 blocks.

2005-09-09  Jakub Jelinek  <jakub@redhat.com>

	[BZ #1318]
	* locale/loadarchive.c (_nl_load_locale_from_archive): Free
	normalized_codeset even if p was already normalized.
	Reported by Jaroslav Snajdr <jsnajdr@kerio.com>.

--- libc/locale/loadarchive.c.jj	2003-09-14 20:13:40.000000000 +0200
+++ libc/locale/loadarchive.c	2005-09-09 18:05:25.000000000 +0200
@@ -1,5 +1,5 @@
 /* Code to load locale data from the locale archive file.
-   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2005 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
@@ -185,9 +185,9 @@ _nl_load_locale_from_archive (int catego
 	    memcpy (__mempcpy (__mempcpy (newname, name, p - name),
 			       normalized_codeset, normlen),
 		    rest, restlen);
-	    free ((char *) normalized_codeset);
 	    name = newname;
 	  }
+	free ((char *) normalized_codeset);
       }
   }
 

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix memory leak in loadarchive.c (BZ #1318)
  2005-09-09 16:17 [PATCH] Fix memory leak in loadarchive.c (BZ #1318) Jakub Jelinek
@ 2005-09-09 16:59 ` Ulrich Drepper
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Drepper @ 2005-09-09 16:59 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Glibc hackers

[-- Attachment #1: Type: text/plain, Size: 101 bytes --]

Applied.

-- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 251 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-09-09 16:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-09 16:17 [PATCH] Fix memory leak in loadarchive.c (BZ #1318) Jakub Jelinek
2005-09-09 16:59 ` Ulrich Drepper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).