about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-01-08 17:21:48 +0000
committerUlrich Drepper <drepper@redhat.com>2001-01-08 17:21:48 +0000
commitcf1bb6d5c03ea7e3b3e02e8a427e0c504a17d44b (patch)
tree6444fa7f58ee19258ec7c0899c9155f5f82ec876
parent1950ebc6cb9f699db2cb62b3a203e95d6e1f5e65 (diff)
downloadglibc-cf1bb6d5c03ea7e3b3e02e8a427e0c504a17d44b.tar.gz
glibc-cf1bb6d5c03ea7e3b3e02e8a427e0c504a17d44b.tar.xz
glibc-cf1bb6d5c03ea7e3b3e02e8a427e0c504a17d44b.zip
Update.
	* malloc/memusage.c (me): Use access() to determine whether we
	should write the output file or not.
-rw-r--r--ChangeLog3
-rw-r--r--malloc/memusage.c5
2 files changed, 6 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 593786368f..0b16263f61 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2001-01-08  Ulrich Drepper  <drepper@redhat.com>
 
+	* malloc/memusage.c (me): Use access() to determine whether we
+	should write the output file or not.
+
 	* libio/bits/stdio.h (printf): Define macro to map printf call to
 	fprintf which gcc can optimize.
 	* stdio-common/printf.c: Undefine printf.
diff --git a/malloc/memusage.c b/malloc/memusage.c
index 34e33475e3..7d1ee94b56 100644
--- a/malloc/memusage.c
+++ b/malloc/memusage.c
@@ -1,5 +1,5 @@
 /* Profile heap and stack memory usage of running program.
-   Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
@@ -200,7 +200,8 @@ me (void)
   if (!not_me && fd == -1)
     {
       const char *outname = getenv ("MEMUSAGE_OUTPUT");
-      if (outname != NULL)
+      if (outname != NULL && outname[0] != '\0'
+	  && access (outname, R_OK | W_OK) == 0)
 	{
 	  fd = creat (outname, 0666);