Skip to content

PyType_FromSpec may leak memory with repeated slot IDs #93466

@encukou

Description

@encukou

If a slot ID is repeated in PyType_Spec, the current PyType_FromSpec implementation happens to usually use the last one and ignore earlier ones, but:

  • if Py_tp_doc is repeated, PyType_FromSpec may leak memory, and
  • if Py_tp_members is repeated, PyType_FromSpec may memcpy unintialized memory (if slot specifies fewer members than the last one).

We chould:

  • clarify in the docs that repeated slot IDs are not supported
  • raise an exception for duplicate slots (at least when it's easy to detect, as in the cases above)

Alternatively, we could formalize that the last slot of a given ID “wins” and fix the leak/mem issue, but I don't see a use case for this more complex behavior.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy