This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: memcpy(NULL, NULL, 0) in array_new()
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: jwilk, python-dev
Priority: normal Keywords: patch

Created on 2014-10-10 19:15 by jwilk, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit
229023.patch jwilk, 2014-10-10 19:19 review
Messages (3)
msg229023 - (view) Author: Jakub Wilk (jwilk) Date: 2014-10-10 19:18
If you initialize array with another empty array, then this code runs:

    memcpy(self->ob_item, other->ob_item, len * other->ob_descr->itemsize);

But self->ob_item and other->ob_item are NULL in such case.
Passing null pointer to memcpy() is undefined behavior even when length is 0.
msg229024 - (view) Author: Jakub Wilk (jwilk) Date: 2014-10-10 19:19
The attached patch should fix the bug.
msg229054 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-10-11 00:58
New changeset 4563fff4e099 by Benjamin Peterson in branch '3.4':
prevent passing NULL to memcpy (closes #22605)

New changeset 8165e44594c2 by Benjamin Peterson in branch 'default':
merge 3.4 (closes #22605)
Date User Action Args
2022-04-11 14:58:08adminsetgithub: 66795
2014-10-11 00:58:50python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg229054

resolution: fixed
stage: resolved
2014-10-10 19:19:48jwilksetfiles: + 229023.patch
keywords: + patch
messages: + msg229024
2014-10-10 19:18:23jwilksetmessages: + msg229023
title: memcpy(NULL, NULL, 0) in -> memcpy(NULL, NULL, 0) in array_new()
2014-10-10 19:15:10jwilkcreate