aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2018-08-13 15:45:17 -0700
committerPaul Eggert2018-08-13 15:55:53 -0700
commit76101698a770d389f22b547c331ec78473040c47 (patch)
tree411115b04cec15dcc216e67818080221dbdaecf5 /src
parenteb787d749f28583906428269b926fa83aef092b9 (diff)
downloademacs-76101698a770d389f22b547c331ec78473040c47.tar.gz
emacs-76101698a770d389f22b547c331ec78473040c47.zip
Fix check for unsafe watch descriptor
* 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.
Diffstat (limited to 'src')
-rw-r--r--src/gfilenotify.c7
-rw-r--r--src/lisp.h8
2 files changed, 10 insertions, 5 deletions
diff --git a/src/gfilenotify.c b/src/gfilenotify.c
index 7eea2cfac1c..798f308b315 100644
--- a/src/gfilenotify.c
+++ b/src/gfilenotify.c
@@ -77,7 +77,6 @@ dir_monitor_callback (GFileMonitor *monitor,
77 77
78 /* Determine callback function. */ 78 /* Determine callback function. */
79 monitor_object = make_pointer_integer (monitor); 79 monitor_object = make_pointer_integer (monitor);
80 eassert (FIXNUMP (monitor_object));
81 watch_object = assq_no_quit (monitor_object, watch_list); 80 watch_object = assq_no_quit (monitor_object, watch_list);
82 81
83 if (CONSP (watch_object)) 82 if (CONSP (watch_object))
@@ -203,10 +202,10 @@ will be reported only in case of the `moved' event. */)
203 if (! monitor) 202 if (! monitor)
204 xsignal2 (Qfile_notify_error, build_string ("Cannot watch file"), file); 203 xsignal2 (Qfile_notify_error, build_string ("Cannot watch file"), file);
205 204
206 Lisp_Object watch_descriptor = make_pointer_integer (monitor); 205 Lisp_Object watch_descriptor = make_pointer_integer_unsafe (monitor);
207 206
208 /* Check the dicey assumption that make_pointer_integer is safe. */ 207 if (! (FIXNUMP (watch_descriptor)
209 if (! FIXNUMP (watch_descriptor)) 208 && XFIXNUMPTR (watch_descriptor) == monitor))
210 { 209 {
211 g_object_unref (monitor); 210 g_object_unref (monitor);
212 xsignal2 (Qfile_notify_error, build_string ("Unsupported file watcher"), 211 xsignal2 (Qfile_notify_error, build_string ("Unsupported file watcher"),
diff --git a/src/lisp.h b/src/lisp.h
index b7ef8dc63a0..18d53537cca 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -1189,9 +1189,15 @@ XFIXNUMPTR (Lisp_Object a)
1189} 1189}
1190 1190
1191INLINE Lisp_Object 1191INLINE Lisp_Object
1192make_pointer_integer_unsafe (void *p)
1193{
1194 return TAG_PTR (Lisp_Int0, p);
1195}
1196
1197INLINE Lisp_Object
1192make_pointer_integer (void *p) 1198make_pointer_integer (void *p)
1193{ 1199{
1194 Lisp_Object a = TAG_PTR (Lisp_Int0, p); 1200 Lisp_Object a = make_pointer_integer_unsafe (p);
1195 eassert (FIXNUMP (a) && XFIXNUMPTR (a) == p); 1201 eassert (FIXNUMP (a) && XFIXNUMPTR (a) == p);
1196 return a; 1202 return a;
1197} 1203}