##// END OF EJS Templates
osutil: fix memory leak of PyBytes of path in statfiles...
Augie Fackler -
r23966:2d2c0a8e stable
parent child Browse files
Show More
@@ -410,17 +410,22 b' static PyObject *statfiles(PyObject *sel'
410 return NULL;
410 return NULL;
411
411
412 for (i = 0; i < count; i++) {
412 for (i = 0; i < count; i++) {
413 PyObject *stat;
413 PyObject *stat, *pypath;
414 struct stat st;
414 struct stat st;
415 int ret, kind;
415 int ret, kind;
416 char *path;
416 char *path;
417
417
418 path = PyString_AsString(PySequence_GetItem(names, i));
418 pypath = PySequence_GetItem(names, i);
419 if (!pypath)
420 return NULL;
421 path = PyString_AsString(pypath);
419 if (path == NULL) {
422 if (path == NULL) {
423 Py_DECREF(pypath);
420 PyErr_SetString(PyExc_TypeError, "not a string");
424 PyErr_SetString(PyExc_TypeError, "not a string");
421 goto bail;
425 goto bail;
422 }
426 }
423 ret = lstat(path, &st);
427 ret = lstat(path, &st);
428 Py_DECREF(pypath);
424 kind = st.st_mode & S_IFMT;
429 kind = st.st_mode & S_IFMT;
425 if (ret != -1 && (kind == S_IFREG || kind == S_IFLNK)) {
430 if (ret != -1 && (kind == S_IFREG || kind == S_IFLNK)) {
426 stat = makestat(&st);
431 stat = makestat(&st);
General Comments 0
You need to be logged in to leave comments. Login now