]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix check for unsafe watch descriptor
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 13 Aug 2018 22:45:17 +0000 (15:45 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 13 Aug 2018 22:55:53 +0000 (15:55 -0700)
* src/lisp.h (make_pointer_integer_unsafe): New function.
(make_pointer_integer): Use it.
* src/gfilenotify.c (dir_monitor_callback): Omit redundant eassert.
(Fgfile_add_watch): Signal an error instead of failing an
assertion if the pointer does not work.

src/gfilenotify.c
src/lisp.h

index 7eea2cfac1c399b83e560b2c112fce7832c01975..798f308b315c3486429928a9912502867511e247 100644 (file)
@@ -77,7 +77,6 @@ dir_monitor_callback (GFileMonitor *monitor,
 
   /* Determine callback function.  */
   monitor_object = make_pointer_integer (monitor);
-  eassert (FIXNUMP (monitor_object));
   watch_object = assq_no_quit (monitor_object, watch_list);
 
   if (CONSP (watch_object))
@@ -203,10 +202,10 @@ will be reported only in case of the `moved' event.  */)
   if (! monitor)
     xsignal2 (Qfile_notify_error, build_string ("Cannot watch file"), file);
 
-  Lisp_Object watch_descriptor = make_pointer_integer (monitor);
+  Lisp_Object watch_descriptor = make_pointer_integer_unsafe (monitor);
 
-  /* Check the dicey assumption that make_pointer_integer is safe.  */
-  if (! FIXNUMP (watch_descriptor))
+  if (! (FIXNUMP (watch_descriptor)
+        && XFIXNUMPTR (watch_descriptor) == monitor))
     {
       g_object_unref (monitor);
       xsignal2 (Qfile_notify_error, build_string ("Unsupported file watcher"),
index b7ef8dc63a04010af71fba8a65083dc2765d7340..18d53537ccacc89362d331e6d6dc25ee2c607be3 100644 (file)
@@ -1188,10 +1188,16 @@ XFIXNUMPTR (Lisp_Object a)
   return XUNTAG (a, Lisp_Int0, char);
 }
 
+INLINE Lisp_Object
+make_pointer_integer_unsafe (void *p)
+{
+  return TAG_PTR (Lisp_Int0, p);
+}
+
 INLINE Lisp_Object
 make_pointer_integer (void *p)
 {
-  Lisp_Object a = TAG_PTR (Lisp_Int0, p);
+  Lisp_Object a = make_pointer_integer_unsafe (p);
   eassert (FIXNUMP (a) && XFIXNUMPTR (a) == p);
   return a;
 }