From 82532f657f7acc824745406e8917a1a4f49723d9 Mon Sep 17 00:00:00 2001 From: Robert Cochran Date: Sun, 21 Aug 2016 19:01:14 -0700 Subject: [PATCH] Signal an error when a TTY frame tries to create an xwidget * src/xwidget.c (make-xwidget): signal an error if current frame is a TTY frame. Trying to use a TTY frame to create an xwidget can cause a segfault. Check before hand that the frame is an X frame via check_x_display_info, which will signal an error if it is not. This fixes Bug#24041. --- src/xwidget.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/xwidget.c b/src/xwidget.c index f5f4da0..0edfacc 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -99,8 +99,15 @@ Returns the newly constructed xwidget, or nil if construction fails. */) CHECK_NATNUM (width); CHECK_NATNUM (height); - struct xwidget *xw = allocate_xwidget (); + struct xwidget *xw; Lisp_Object val; + + /* Ensure that the current frame is an X frame before we try + creating any xwidgets. If it isn't, check_x_display_info will + signal an error. */ + check_x_display_info (Fselected_frame ()); + + xw = allocate_xwidget (); xw->type = type; xw->title = title; xw->buffer = NILP (buffer) ? Fcurrent_buffer () : Fget_buffer_create (buffer); -- 2.7.4