Memory bug fixed
Andreas Jaeger
aj@suse.de
Thu Jul 13 09:40:00 GMT 2000
>>>>> Ulrich Drepper writes:
Uli> Andreas Jaeger <aj@suse.de> writes:
>> Shall I revert the patch and change fgetspent.c also? Should we teach
>> mtrace to not emit an error message for free(0) ?
Uli> Yes and yes.
Here's a patch. Is this one ok?
Andreas
2000-07-13 Andreas Jaeger <aj@suse.de>
* malloc/mtrace.pl (location): Ignore free(0).
* sysdeps/unix/sysv/linux/getsysstats.c (free_mem): Revert last
patch.
* grp/fgetgrent.c (free_mem): Remove if - free (0) is valid.
* inet/getnetgrent.c (free_mem): Likewise.
* misc/mntent.c (free_mem): Likewise.
* nss/getXXbyYY.c (free_mem): Likewise.
* nss/getXXent.c (free_mem): Likewise.
* pwd/fgetpwent.c (free_mem): Likewise.
* shadow/fgetspent.c (free_mem): Likewise.
============================================================
Index: shadow/fgetspent.c
--- shadow/fgetspent.c 1999/06/09 12:01:12 1.6
+++ shadow/fgetspent.c 2000/07/13 16:29:21
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1999, 2000 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
@@ -92,8 +92,7 @@
static void __attribute__ ((unused))
free_mem (void)
{
- if (buffer != NULL)
- free (buffer);
+ free (buffer);
}
text_set_element (__libc_subfreeres, free_mem);
============================================================
Index: pwd/fgetpwent.c
--- pwd/fgetpwent.c 1999/06/09 11:58:48 1.11
+++ pwd/fgetpwent.c 2000/07/13 16:29:21
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1996, 1997, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996, 1997, 1999, 2000 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
@@ -89,8 +89,7 @@
static void __attribute__ ((unused))
free_mem (void)
{
- if (buffer != NULL)
- free (buffer);
+ free (buffer);
}
text_set_element (__libc_subfreeres, free_mem);
============================================================
Index: sysdeps/unix/sysv/linux/getsysstats.c
--- sysdeps/unix/sysv/linux/getsysstats.c 2000/07/13 09:50:03 1.13
+++ sysdeps/unix/sysv/linux/getsysstats.c 2000/07/13 16:29:22
@@ -283,7 +283,6 @@
static void
free_mem (void)
{
- if (mount_proc != NULL)
- free (mount_proc);
+ free (mount_proc);
}
text_set_element (__libc_subfreeres, free_mem);
============================================================
Index: nss/getXXent.c
--- nss/getXXent.c 1999/06/17 12:31:25 1.10
+++ nss/getXXent.c 2000/07/13 16:29:22
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1999, 2000 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
@@ -121,8 +121,7 @@
static void __attribute__ ((unused))
free_mem (void)
{
- if (buffer != NULL)
- free (buffer);
+ free (buffer);
}
text_set_element (__libc_subfreeres, free_mem);
============================================================
Index: nss/getXXbyYY.c
--- nss/getXXbyYY.c 1999/12/04 18:00:10 1.17
+++ nss/getXXbyYY.c 2000/07/13 16:29:22
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998, 1999, 2000 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
@@ -164,8 +164,7 @@
static void __attribute__ ((unused))
free_mem (void)
{
- if (buffer != NULL)
- free (buffer);
+ free (buffer);
}
text_set_element (__libc_subfreeres, free_mem);
============================================================
Index: misc/mntent.c
--- misc/mntent.c 1997/10/31 22:45:25 1.7
+++ misc/mntent.c 2000/07/13 16:29:22
@@ -1,5 +1,5 @@
/* Utilities for reading/writing fstab, mtab, etc.
- Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 2000 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
@@ -60,8 +60,7 @@
__attribute__ ((unused))
free_mem (void)
{
- if (getmntent_buffer != NULL)
- free (getmntent_buffer);
+ free (getmntent_buffer);
}
text_set_element (__libc_subfreeres, free_mem);
============================================================
Index: inet/getnetgrent.c
--- inet/getnetgrent.c 1997/10/31 22:43:17 1.3
+++ inet/getnetgrent.c 2000/07/13 16:29:22
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 2000 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
@@ -56,8 +56,7 @@
__attribute__ ((unused))
free_mem (void)
{
- if (buffer != NULL)
- free (buffer);
+ free (buffer);
}
text_set_element (__libc_subfreeres, free_mem);
============================================================
Index: grp/fgetgrent.c
--- grp/fgetgrent.c 2000/04/21 15:59:39 1.15
+++ grp/fgetgrent.c 2000/07/13 16:29:22
@@ -89,8 +89,7 @@
static void __attribute__ ((unused))
free_mem (void)
{
- if (buffer != NULL)
- free (buffer);
+ free (buffer);
}
text_set_element (__libc_subfreeres, free_mem);
============================================================
Index: malloc/mtrace.pl
--- malloc/mtrace.pl 2000/07/07 08:03:07 1.6
+++ malloc/mtrace.pl 2000/07/13 16:29:22
@@ -139,6 +139,9 @@
if (defined $allocated{$allocaddr}) {
undef $allocated{$allocaddr};
undef $wherewas{$allocaddr};
+ } elsif ($allocaddr == 0) {
+ # Ignore free (0)
+ undef $wherewas{$allocaddr};
} else {
printf ("- %#0@XXX@x Free %d was never alloc'd %s\n",
hex($allocaddr), $nr, &location($where));
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
More information about the Libc-hacker
mailing list