summaryrefslogtreecommitdiff
path: root/src/sysdep.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2018-02-20 05:58:58 +0200
committerEli Zaretskii <eliz@gnu.org>2018-02-20 05:58:58 +0200
commit3d42272754db914d4f2dbbcfba5ce6776a7b232b (patch)
tree70d74f9adfbf9614c1f66f07c0c7f66ecfbe5991 /src/sysdep.c
parent071a0a571243f9498e0e58e5fe938a7b892a22db (diff)
downloademacs-3d42272754db914d4f2dbbcfba5ce6776a7b232b.tar.gz
Add assertion to guard 'read' calls on MS-Windows
* src/sysdep.c (emacs_intr_read): Assert that NBYTES never overflows a 32-bit int.
Diffstat (limited to 'src/sysdep.c')
-rw-r--r--src/sysdep.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/sysdep.c b/src/sysdep.c
index bc34d8dc059..08db376b261 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -2566,6 +2566,14 @@ emacs_intr_read (int fd, void *buf, ptrdiff_t nbyte, bool interruptible)
/* There is no need to check against MAX_RW_COUNT, since no caller ever
passes a size that large to emacs_read. */
+#ifdef WINDOWSNT
+ /* On MS-Windows, 'read's last argument is declared as 'unsigned
+ int', and the return value's type (see 'sys_read') is 'int'.
+ This might cause trouble, especially in 64-bit builds, if the
+ above comment ever becomes incorrect. The following assertion
+ should make us more future-proof. */
+ eassert (nbyte <= INT_MAX);
+#endif
do
{
if (interruptible)