mercurial/osutil.c
branchstable
changeset 23966 2d2c0a8eeeb8
parent 23962 1f3b94e8dc40
child 24460 73477e755cd2
--- a/mercurial/osutil.c	Tue Jan 27 19:52:26 2015 -0800
+++ b/mercurial/osutil.c	Tue Jan 27 10:17:16 2015 -0500
@@ -410,17 +410,22 @@
 		return NULL;
 
 	for (i = 0; i < count; i++) {
-		PyObject *stat;
+		PyObject *stat, *pypath;
 		struct stat st;
 		int ret, kind;
 		char *path;
 
-		path = PyString_AsString(PySequence_GetItem(names, i));
+		pypath = PySequence_GetItem(names, i);
+		if (!pypath)
+			return NULL;
+		path = PyString_AsString(pypath);
 		if (path == NULL) {
+			Py_DECREF(pypath);
 			PyErr_SetString(PyExc_TypeError, "not a string");
 			goto bail;
 		}
 		ret = lstat(path, &st);
+		Py_DECREF(pypath);
 		kind = st.st_mode & S_IFMT;
 		if (ret != -1 && (kind == S_IFREG || kind == S_IFLNK)) {
 			stat = makestat(&st);