unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Lee Duhem <lee.duhem@gmail.com>
To: emacs-devel@gnu.org
Cc: Andreas Schwab <schwab@suse.de>,
	Stefan Monnier <monnier@iro.umontreal.ca>
Subject: [PATCH] Protect arguments needed after eval_sub calls in Fdefvar and Fdefconst
Date: Thu, 20 Nov 2014 10:31:22 +0800	[thread overview]
Message-ID: <CAOSer0DC3_VQT4uLu+5X8vmgLYQxqjsr+jZCYn-ugqPwzEZEbw@mail.gmail.com> (raw)

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  <lee.duhem@gmail.com>
+ * eval.c (Fdefvar, Fdefconst): Protect arguments needed after
+ `eval_sub' calls.
+
 2014-11-17  Paul Eggert  <eggert@cs.ucla.edu>

  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



                 reply	other threads:[~2014-11-20  2:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOSer0DC3_VQT4uLu+5X8vmgLYQxqjsr+jZCYn-ugqPwzEZEbw@mail.gmail.com \
    --to=lee.duhem@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=schwab@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).