From fe150036803ce14efbf3a1e7bf923f47eded0179 Mon Sep 17 00:00:00 2001 From: Meador Inge Date: Tue, 27 Sep 2011 20:35:28 -0500 Subject: [PATCH] Issue #13013: ctypes: Fix a reference leak in PyCArrayType_from_ctype. Thanks to Suman Saha for finding the bug and providing a patch. --- Misc/ACKS | 1 + Misc/NEWS | 3 +++ Modules/_ctypes/_ctypes.c | 1 + 3 files changed, 5 insertions(+) diff --git a/Misc/ACKS b/Misc/ACKS index e728c511e13..6c02a79c7a8 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -720,6 +720,7 @@ Sam Rushing Mark Russell Nick Russo Sébastien Sablé +Suman Saha Hajime Saitou George Sakkis Rich Salz diff --git a/Misc/NEWS b/Misc/NEWS index c4f0cb09fe6..132ea5e08b9 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -207,6 +207,9 @@ Library Extension Modules ----------------- +- Issue #13013: ctypes: Fix a reference leak in PyCArrayType_from_ctype. + Thanks to Suman Saha for finding the bug and providing a patch. + - Issue #13022: Fix: _multiprocessing.recvfd() doesn't check that file descriptor was actually received. diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index c4d08901cd3..4ae2c4133e8 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -4678,6 +4678,7 @@ PyCArrayType_from_ctype(PyObject *itemtype, Py_ssize_t length) if (!PyType_Check(itemtype)) { PyErr_SetString(PyExc_TypeError, "Expected a type object"); + Py_DECREF(key); return NULL; } #ifdef MS_WIN64