# HG changeset patch # User Karoly Lorentey # Date 1113830260 0 # Node ID b4b67a7fcbe09909a0570f17fdd935d8dcd363e3 # Parent 9deb6323655c41970214056165c35f90c0e92c4a Resolve crashes related to face aliases. * src/xfaces.c (internal_resolve_face_name, resolve_face_name_error): New functions. (resolve_face_name): Protect against loops and errors thrown by Fget. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-327 diff -r 9deb6323655c -r b4b67a7fcbe0 src/xfaces.c --- a/src/xfaces.c Mon Apr 11 12:40:15 2005 +0000 +++ b/src/xfaces.c Mon Apr 18 13:17:40 2005 +0000 @@ -3204,6 +3204,20 @@ +static Lisp_Object +internal_resolve_face_name (nargs, args) + int nargs; + Lisp_Object *args; +{ + Fget (args[0], args[1]); +} + +static Lisp_Object +resolve_face_name_error (ignore) + Lisp_Object ignore; +{ + return Qnil; +} /* Resolve face name FACE_NAME. If FACE_NAME is a string, intern it to make it a symvol. If FACE_NAME is an alias for another face, @@ -3214,17 +3228,25 @@ Lisp_Object face_name; { Lisp_Object aliased; + Lisp_Object args[2]; + int c = 0; if (STRINGP (face_name)) face_name = intern (SDATA (face_name)); - while (SYMBOLP (face_name)) - { - aliased = Fget (face_name, Qface_alias); + /* Protect against loops by limiting the number of indirections. */ + while (SYMBOLP (face_name) && c < 10) + { + /* Fget can signal an error; just ignore it. */ + args[0] = face_name; + args[1] = Qface_alias; + aliased = internal_condition_case_2 (internal_resolve_face_name, 2, args, Qt, + resolve_face_name_error); if (NILP (aliased)) break; else face_name = aliased; + c++; } return face_name;