Skip to content

Commit

Permalink
Don't overallocate memory in attrs_from_List()
Browse files Browse the repository at this point in the history
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 <cheimes@redhat.com>
  • Loading branch information
Christian Heimes authored and GitHub committed Jun 5, 2020
1 parent 3c0f7ef commit a7671d8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Modules/LDAPObject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a7671d8

Please sign in to comment.