emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 3d42272: Add assertion to guard 'read' calls on MS-


From: Eli Zaretskii
Subject: [Emacs-diffs] master 3d42272: Add assertion to guard 'read' calls on MS-Windows
Date: Mon, 19 Feb 2018 23:00:25 -0500 (EST)

branch: master
commit 3d42272754db914d4f2dbbcfba5ce6776a7b232b
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Add assertion to guard 'read' calls on MS-Windows
    
    * src/sysdep.c (emacs_intr_read): Assert that NBYTES never
    overflows a 32-bit int.
---
 src/sysdep.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/sysdep.c b/src/sysdep.c
index bc34d8d..08db376 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]