[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master f3b24e9: Add assertion to STRING_SET_CHARS
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] master f3b24e9: Add assertion to STRING_SET_CHARS |
Date: |
Sun, 16 Apr 2017 03:27:37 -0400 (EDT) |
branch: master
commit f3b24e90dc9fad355102e1fdf2828ca33d447a07
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>
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.
---
src/lisp.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/lisp.h b/src/lisp.h
index 678e261..e0bad58 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -1369,6 +1369,10 @@ SBYTES (Lisp_Object string)
INLINE void
STRING_SET_CHARS (Lisp_Object string, ptrdiff_t newsize)
{
+ /* This function cannot change the size of data allocated for the
+ string when it was created. */
+ eassert ((STRING_MULTIBYTE (string) && newsize <= SBYTES (string))
+ || (!STRING_MULTIBYTE (string) && newsize == SCHARS (string)));
XSTRING (string)->size = newsize;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master f3b24e9: Add assertion to STRING_SET_CHARS,
Eli Zaretskii <=