diff options
| author | Eli Zaretskii | 2017-04-16 10:27:23 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2017-04-16 10:27:23 +0300 |
| commit | f3b24e90dc9fad355102e1fdf2828ca33d447a07 (patch) | |
| tree | 8d557af42dac0fde976e40984780a78c2f5bdb8a /src | |
| parent | 1bf7ca623b3d3e02617cf0b5f8d7f980384838d3 (diff) | |
| download | emacs-f3b24e90dc9fad355102e1fdf2828ca33d447a07.tar.gz emacs-f3b24e90dc9fad355102e1fdf2828ca33d447a07.zip | |
Add assertion to STRING_SET_CHARS
* src/lisp.h (STRING_SET_CHARS): Add an assertion and commentary
to prevent incorrect usage. For details, see this discussion:
http://lists.gnu.org/archive/html/emacs-devel/2017-04/msg00412.html.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lisp.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/lisp.h b/src/lisp.h index 678e261c1da..e0bad58f758 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -1369,6 +1369,10 @@ SBYTES (Lisp_Object string) | |||
| 1369 | INLINE void | 1369 | INLINE void |
| 1370 | STRING_SET_CHARS (Lisp_Object string, ptrdiff_t newsize) | 1370 | STRING_SET_CHARS (Lisp_Object string, ptrdiff_t newsize) |
| 1371 | { | 1371 | { |
| 1372 | /* This function cannot change the size of data allocated for the | ||
| 1373 | string when it was created. */ | ||
| 1374 | eassert ((STRING_MULTIBYTE (string) && newsize <= SBYTES (string)) | ||
| 1375 | || (!STRING_MULTIBYTE (string) && newsize == SCHARS (string))); | ||
| 1372 | XSTRING (string)->size = newsize; | 1376 | XSTRING (string)->size = newsize; |
| 1373 | } | 1377 | } |
| 1374 | 1378 | ||