From c7bda33cad5112de8c093dce0eaf62c84fb32063 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 17 Apr 2011 21:25:27 -0700 Subject: [PATCH] * alloc.c (allocate_buffer): Don't assume sizeof (struct buffer) is a multiple of sizeof (EMACS_INT); it need not be, if alignof(EMACS_INT) < sizeof (EMACS_INT). --- src/ChangeLog | 3 +++ src/alloc.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index fa2aa03233d..81053d74480 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -6,6 +6,9 @@ don't formally overflow signed char, to avoid warnings. (allocate_string_data) [GC_CHECK_STRING_OVERRUN]: Fix typo that can cause Emacs to crash when string overrun checking is enabled. + (allocate_buffer): Don't assume sizeof (struct buffer) is a + multiple of sizeof (EMACS_INT); it need not be, if + alignof(EMACS_INT) < sizeof (EMACS_INT). 2011-04-17 Chong Yidong diff --git a/src/alloc.c b/src/alloc.c index 2af75e3c471..2d1c8ffe70b 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1055,7 +1055,8 @@ allocate_buffer (void) struct buffer *b = (struct buffer *) lisp_malloc (sizeof (struct buffer), MEM_TYPE_BUFFER); - b->size = sizeof (struct buffer) / sizeof (EMACS_INT); + b->size = ((sizeof (struct buffer) + sizeof (EMACS_INT) - 1) + / sizeof (EMACS_INT)); XSETPVECTYPE (b, PVEC_BUFFER); return b; } -- 2.39.2