]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix problems reported by valgrind:
authorNeal Norwitz <nnorwitz@gmail.com>
Mon, 19 Sep 2005 06:42:30 +0000 (06:42 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Mon, 19 Sep 2005 06:42:30 +0000 (06:42 +0000)
 * Fix memory leak in posix.access()
 * Fix use of uninitialized value in forkpty()
   - from the manpage it isn't clear if there are conditions where master_fd
     are uninitialized, but it's safer to initialize

Modules/posixmodule.c

index a116c41d5e10c183b3a74ec1c19c3446cfe38547..0649854f5524fc0d77909cd1a8c4bcf765e48729 100644 (file)
@@ -1119,6 +1119,7 @@ posix_access(PyObject *self, PyObject *args)
        Py_BEGIN_ALLOW_THREADS
        res = access(path, mode);
        Py_END_ALLOW_THREADS
+       PyMem_Free(path);
        return(PyBool_FromLong(res == 0));
 }
 
@@ -2950,7 +2951,7 @@ To both, return fd of newly opened pseudo-terminal.\n");
 static PyObject *
 posix_forkpty(PyObject *self, PyObject *noargs)
 {
-       int master_fd, pid;
+       int master_fd = -1, pid;
 
        pid = forkpty(&master_fd, NULL, NULL, NULL);
        if (pid == -1)