From a7671d84bc9aea322c6cb36468a91c02543ebf9d Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Fri, 5 Jun 2020 16:17:02 +0200 Subject: [PATCH] Don't overallocate memory in attrs_from_List() Allocate ``(strlen + 1) * sizeof(char)`` instead of ``(strlen + 1) * sizeof(char*)`` for a ``char[]`` in ``attrs_from_List()``. https://github.com/python-ldap/python-ldap/pull/340 Signed-off-by: Christian Heimes --- Modules/LDAPObject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/LDAPObject.c b/Modules/LDAPObject.c index 0f52d22..a2ff626 100644 --- a/Modules/LDAPObject.c +++ b/Modules/LDAPObject.c @@ -335,7 +335,7 @@ attrs_from_List(PyObject *attrlist, char ***attrsp) * internal values that must be treated like const char. Python * 3.7 actually returns a const char. */ - attrs[i] = (char *)PyMem_NEW(char *, strlen + 1); + attrs[i] = (char *)PyMem_NEW(char, strlen + 1); if (attrs[i] == NULL) goto nomem;