mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-04-27 16:51:06 -07:00
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.
This commit is contained in:
parent
eb787d749f
commit
76101698a7
2 changed files with 10 additions and 5 deletions
|
|
@ -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"),
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue