This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
FYI: fix erroneous `sizeof'
- From: Tom Tromey <tromey at redhat dot com>
- To: Binutils Development <binutils at sourceware dot org>
- Date: Thu, 28 Apr 2011 14:36:32 -0600
- Subject: FYI: fix erroneous `sizeof'
I am checking this in as obvious.
A static analysis tool pointed out this bad `sizeof'. It seems clear
that the intent is to zero out the whole struct stat, not just the first
word of it.
Tom
2011-04-28 Tom Tromey <tromey@redhat.com>
* bfdio.c (memory_bstat): Pass correct size to memset.
Index: bfdio.c
===================================================================
RCS file: /cvs/src/src/bfd/bfdio.c,v
retrieving revision 1.27
diff -u -r1.27 bfdio.c
--- bfdio.c 9 Jun 2010 13:28:31 -0000 1.27
+++ bfdio.c 28 Apr 2011 20:33:17 -0000
@@ -1,7 +1,7 @@
/* Low-level I/O routines for BFDs.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011
Free Software Foundation, Inc.
Written by Cygnus Support.
@@ -577,7 +577,7 @@
{
struct bfd_in_memory *bim = (struct bfd_in_memory *) abfd->iostream;
- memset (statbuf, 0, sizeof (statbuf));
+ memset (statbuf, 0, sizeof (*statbuf));
statbuf->st_size = bim->size;
return 0;