summaryrefslogtreecommitdiff
path: root/gdb/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/utils.c')
-rw-r--r--gdb/utils.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/gdb/utils.c b/gdb/utils.c
index 0d89cb7b561..164bc9c1648 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -215,14 +215,17 @@ make_cleanup_bfd_close (bfd *abfd)
static void
do_close_cleanup (void *arg)
{
- close ((int) arg);
+ int *fd = arg;
+ close (*fd);
+ xfree (fd);
}
struct cleanup *
make_cleanup_close (int fd)
{
- /* int into void*. Outch!! */
- return make_cleanup (do_close_cleanup, (void *) fd);
+ int *saved_fd = xmalloc (sizeof (fd));
+ *saved_fd = fd;
+ return make_cleanup (do_close_cleanup, saved_fd);
}
static void