unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: 11243@debbugs.gnu.org
Subject: bug#11243: decode_env_path garbage-collection bug
Date: Sat, 14 Apr 2012 00:09:39 -0700	[thread overview]
Message-ID: <4F8922B3.8020207@cs.ucla.edu> (raw)

Tags: patch

Here's the obvious patch, which I plan to install in the
trunk after a bit more testing.

=== modified file 'src/ChangeLog'
--- src/ChangeLog	2012-04-14 06:18:49 +0000
+++ src/ChangeLog	2012-04-14 07:06:24 +0000
@@ -1,5 +1,10 @@
 2012-04-14  Paul Eggert  <eggert@cs.ucla.edu>
 
+	Fix possible memory crash in decode_env_path.
+	* emacs.c (decode_env_path): GCPRO locals.
+
+2012-04-14  Paul Eggert  <eggert@cs.ucla.edu>
+
 	Make GC_MAKE_GCPROS_NOOPS the default (Bug#9926).
 	* lisp.h (GC_MARK_STACK): Default to GC_MAKE_GCPROS_NOOPS.
 	* s/cygwin.h, s/darwin.h, s/freebsd.h, s/gnu.h, s/irix6-5.h, s/msdos.h:

=== modified file 'src/emacs.c'
--- src/emacs.c	2012-04-07 13:57:36 +0000
+++ src/emacs.c	2012-04-14 07:06:24 +0000
@@ -2285,6 +2285,7 @@
 {
   const char *path, *p;
   Lisp_Object lpath, element, tem;
+  struct gcpro gcpro1, gcpro2;
 
   /* It's okay to use getenv here, because this function is only used
      to initialize variables when Emacs starts up, and isn't called
@@ -2305,7 +2306,8 @@
       path = path_copy;
     }
 #endif
-  lpath = Qnil;
+  lpath = element = Qnil;
+  GCPRO2 (lpath, element);
   while (1)
     {
       p = strchr (path, SEPCHAR);
@@ -2337,7 +2339,7 @@
       else
 	break;
     }
-  return Fnreverse (lpath);
+  RETURN_UNGCPRO (Fnreverse (lpath));
 }
 
 DEFUN ("daemonp", Fdaemonp, Sdaemonp, 0, 0, 0,





                 reply	other threads:[~2012-04-14  7:09 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=4F8922B3.8020207@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=11243@debbugs.gnu.org \
    /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).