Re: [PATCH] commit-slab: sizeof() the right type in xrealloc
- From
Jeff King <peff@peff.net>
- Date
- Dec 2, 2013, 15:35 UTC
- Message-ID
- <20131202153513.GA24202@sigill.intra.peff.net>
- In-Reply-To
- <87siucpalo.fsf_-_@linux-1gf2.Speedport_W723_V_Typ_A_1_00_098>
On Sun, Dec 01, 2013 at 09:41:55PM +0100, Thomas Rast wrote:
> When allocating the slab, the code accidentally computed the array > size from s->slab (an elemtype**). The slab is an array of elemtype*, > however, so we should take the size of *s->slab.
Looks obviously correct.
Show 9 quoted lines
> I browsed around for a while, and couldn't find out whether any > architecture actually has any hope of running git (i.e. is at least > mostly POSIX conformant) but still violates the assumption that all > pointers[*] are the same size. > > The comp.lang.c FAQ has some interesting examples of wildly different > pointer representations at: > > http://c-faq.com/null/machexamp.html
Note that most of those examples are not different sizes, but rather different null-pointer representations. We are already grossly out of compliance with the standard there, as we typically use memset() to zero-out structs with pointers.
-Peff