--- emacs-26.1+1.orig/src/alloc.c +++ emacs-26.1+1/src/alloc.c @@ -1766,14 +1766,14 @@ static char const string_overrun_cookie[ /* The 'max' reserves space for the nbytes union member even when NBYTES + 1 is less than the size of that member. The 'max' is not needed when - SDATA_DATA_OFFSET is a multiple of FLEXALIGNOF (struct sdata), - because then the alignment code reserves enough space. */ + the tail padding of "struct sdata" with a single payload byte is big enough + to accomodate the full union "sdata". */ #define SDATA_SIZE(NBYTES) \ ((SDATA_DATA_OFFSET \ - + (SDATA_DATA_OFFSET % FLEXALIGNOF (struct sdata) == 0 \ - ? NBYTES \ - : max (NBYTES, FLEXALIGNOF (struct sdata) - 1)) \ + + (FLEXSIZEOF (struct sdata, data, 1) < sizeof (sdata) \ + ? max (NBYTES, sizeof (sdata) - SDATA_DATA_OFFSET - 1) \ + : NBYTES) \ + 1 \ + FLEXALIGNOF (struct sdata) - 1) \ & ~(FLEXALIGNOF (struct sdata) - 1))