From 652349d0a5b9b9504fc2e9d145c3f2c83776d7df Mon Sep 17 00:00:00 2001 From: Jeff Morriss Date: Fri, 4 May 2012 01:33:58 +0000 Subject: Partial fix for https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7221 (emem alignment problems on SPARC) : Add the room for the pointer to the next (from r31577) *before* calculating the canary+pad: that way the complete allocation (allocation+canary_ptr+canary+pad) will end on an 8-byte boundary (as was the case before r31577). This only solves the alignment problem when using canaries (i.e., not, by default, se_ allocations). (And, yes, this is ignoring the 16-byte alignment requirements of long doubles.) svn path=/trunk/; revision=42407 --- epan/emem.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'epan/emem.c') diff --git a/epan/emem.c b/epan/emem.c index 0e5478efcc..2e9503accc 100644 --- a/epan/emem.c +++ b/epan/emem.c @@ -753,11 +753,12 @@ emem_alloc_chunk(size_t size, emem_header_t *mem) /* Allocate room for at least 8 bytes of canary plus some padding * so the canary ends on an 8-byte boundary. - * Then add the room needed for the pointer to the next canary. + * But first add the room needed for the pointer to the next canary + * (so the entire allocation will end on an 8-byte boundary). */ if (use_canary) { - pad = emem_canary_pad(asize); asize += sizeof(void *); + pad = emem_canary_pad(asize); } else pad = (G_MEM_ALIGN - (asize & (G_MEM_ALIGN-1))) & (G_MEM_ALIGN-1); -- cgit v1.2.3