Submitter | Siddharth Agarwal |
---|---|
Date | April 6, 2015, 7:44 p.m. |
Message ID | <07327bdebb35586d5b3e.1428349451@devbig136.prn2.facebook.com> |
Download | mbox | patch |
Permalink | /patch/8513/ |
State | Accepted |
Headers | show |
Comments
On Mon, 2015-04-06 at 12:44 -0700, Siddharth Agarwal wrote: > # HG changeset patch > # User Siddharth Agarwal <sid0@fb.com> > # Date 1428342404 25200 > # Mon Apr 06 10:46:44 2015 -0700 > # Node ID 07327bdebb35586d5b3e950a32070db16b65d63b > # Parent 4a4018831d2ebc3c9cae9c6613e6a2497b4f0993 > dirs._addpath: don't mutate Python strings after exposing them (issue4589) Queued for default, thanks.
Patch
diff --git a/mercurial/dirs.c b/mercurial/dirs.c --- a/mercurial/dirs.c +++ b/mercurial/dirs.c @@ -93,11 +93,11 @@ static int _addpath(PyObject *dirs, PyOb if (ret == -1) goto bail; - if (pos != 0) - PyString_AS_STRING(key)[pos] = '/'; - else - key = NULL; - Py_CLEAR(key); + /* Clear the key out since we've already exposed it to Python + and can't mutate it further. key's refcount is currently 2 so + we can't just use Py_CLEAR. */ + Py_DECREF(key); + key = NULL; } ret = 0;