From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lee Duhem Newsgroups: gmane.emacs.devel Subject: [PATCH] Protect arguments needed after eval_sub calls in Fdefvar and Fdefconst Date: Thu, 20 Nov 2014 10:31:22 +0800 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1416450695 9459 80.91.229.3 (20 Nov 2014 02:31:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 20 Nov 2014 02:31:35 +0000 (UTC) Cc: Andreas Schwab , Stefan Monnier To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 20 03:31:29 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XrHWq-00041d-9u for ged-emacs-devel@m.gmane.org; Thu, 20 Nov 2014 03:31:28 +0100 Original-Received: from localhost ([::1]:33238 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrHWp-0004Hd-TA for ged-emacs-devel@m.gmane.org; Wed, 19 Nov 2014 21:31:27 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrHWl-0004HN-Vx for emacs-devel@gnu.org; Wed, 19 Nov 2014 21:31:25 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XrHWk-0004iV-RZ for emacs-devel@gnu.org; Wed, 19 Nov 2014 21:31:23 -0500 Original-Received: from mail-qa0-x22d.google.com ([2607:f8b0:400d:c00::22d]:43807) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrHWk-0004iR-Ms for emacs-devel@gnu.org; Wed, 19 Nov 2014 21:31:22 -0500 Original-Received: by mail-qa0-f45.google.com with SMTP id x12so1356372qac.32 for ; Wed, 19 Nov 2014 18:31:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=6RtHTOVbpABXA55t43wHXu/8jVAXdT//Qtr2ga33FeM=; b=Qf8S2GJg/C+mLz0mYfDY0sHrTugEn8nU6HGWrW95bh2a8ram/ql2bJGkOKUe0qThn8 3J7vrBKAr/TfG+TbcUBtDrOp+YyqoaaDnOQI+dqcVsHOdN2NxTrPsCzRstNqNmKaNjXF wCMLWCAwNce9bUX9uWiIHdclqXdYPpBPVdNy/I2pCtDnB2yPFZIxvfwKPidtsi/34CWV xzBcCwtVab1wE0kNE5ImD2ArTiPShKHKri/i1n7GT6qSMF5N6/ozBeYUOXxQdBSCQ/Mg Efyaeny78fTaOPxcn9qLvJ7bBJ4xLGwh7DTGNQ1ZZjkagZsasFtLWnsXW98XQj94BkBm yWlw== X-Received: by 10.224.66.70 with SMTP id m6mr58024267qai.45.1416450682274; Wed, 19 Nov 2014 18:31:22 -0800 (PST) Original-Received: by 10.140.37.37 with HTTP; Wed, 19 Nov 2014 18:31:22 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c00::22d X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:177839 Archived-At: Hi, In the definitions of `Fdefvar' and `Fdefconst', the arguments and/or some local variables are needed after `eval_sub' calls, but are not protected by GCPRO, this patch fix that. Tested on my X86-64 box, it looks like I did not break anything. OK to commit? Sincerely, lee * eval.c (Fdefvar, Fdefconst): Protect arguments needed after `eval_sub' calls. --- src/ChangeLog | 4 ++++ src/eval.c | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/ChangeLog b/src/ChangeLog index b169479..2cfed72 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2014-11-20 Lee Duhem + * eval.c (Fdefvar, Fdefconst): Protect arguments needed after + `eval_sub' calls. + 2014-11-17 Paul Eggert Improve time stamp handling, and be more consistent about it. diff --git a/src/eval.c b/src/eval.c index 77b1db9..01a7eff 100644 --- a/src/eval.c +++ b/src/eval.c @@ -727,12 +727,15 @@ usage: (defvar SYMBOL &optional INITVALUE DOCSTRING) */) (Lisp_Object args) { Lisp_Object sym, tem, tail; + struct gcpro gcpro1; sym = XCAR (args); tail = XCDR (args); if (CONSP (tail)) { + GCPRO1(args); + if (CONSP (XCDR (tail)) && CONSP (XCDR (XCDR (tail)))) error ("Too many arguments"); @@ -761,6 +764,8 @@ usage: (defvar SYMBOL &optional INITVALUE DOCSTRING) */) Fput (sym, Qvariable_documentation, tem); } LOADHIST_ATTACH (sym); + + UNGCPRO; } else if (!NILP (Vinternal_interpreter_environment) && !XSYMBOL (sym)->declared_special) @@ -798,11 +803,13 @@ usage: (defconst SYMBOL INITVALUE [DOCSTRING]) */) (Lisp_Object args) { Lisp_Object sym, tem; + struct gcpro gcpro1; sym = XCAR (args); if (CONSP (Fcdr (XCDR (XCDR (args))))) error ("Too many arguments"); + GCPRO1(args); tem = eval_sub (Fcar (XCDR (args))); if (!NILP (Vpurify_flag)) tem = Fpurecopy (tem); @@ -817,6 +824,7 @@ usage: (defconst SYMBOL INITVALUE [DOCSTRING]) */) } Fput (sym, Qrisky_local_variable, Qt); LOADHIST_ATTACH (sym); + UNGCPRO; return sym; } -- 1.9.3