mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 14:00:21 +02:00
Fix invalid writes to read-only stringbufs.
* libguile/strings.c (SET_STRINGBUF_SHARED): Don't modify BUF if it's already marked as shared since it might be a read-only stringbuf. This error can be caught when linking with GNU ld with "-z relro".
This commit is contained in:
parent
46f9baf49a
commit
9b41542f4d
1 changed files with 9 additions and 2 deletions
|
@ -86,8 +86,15 @@
|
|||
|
||||
#define STRINGBUF_MAX_INLINE_LEN (3*sizeof(scm_t_bits))
|
||||
|
||||
#define SET_STRINGBUF_SHARED(buf) \
|
||||
(SCM_SET_CELL_WORD_0 ((buf), SCM_CELL_WORD_0 (buf) | STRINGBUF_F_SHARED))
|
||||
#define SET_STRINGBUF_SHARED(buf) \
|
||||
do \
|
||||
{ \
|
||||
/* Don't modify BUF if it's already marked as shared since it might be \
|
||||
a read-only, statically allocated stringbuf. */ \
|
||||
if (SCM_LIKELY (!STRINGBUF_SHARED (buf))) \
|
||||
SCM_SET_CELL_WORD_0 ((buf), SCM_CELL_WORD_0 (buf) | STRINGBUF_F_SHARED); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#if SCM_DEBUG
|
||||
static size_t lenhist[1001];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue