Skip to content

Python/instrumentation.c: ensure non-NULL PyLong_FromLong results when possible #134411

Open
@smurav

Description

@smurav

Py_DECREF(val);

Since PyLong_FromLong can return NULL, it is necessary to use Py_XDECREF, as stated in refcount.h.

NULL pointer. If it may be NULL, use Py_XINCREF/Py_XDECREF instead.

Linked PRs

Activity

sergey-miryanov

sergey-miryanov commented on May 21, 2025

@sergey-miryanov
Contributor

It falls to small_int case and can't return NULL. I suggest adding an assert and leave the decref code as is.

smurav

smurav commented on May 21, 2025

@smurav
ContributorAuthor

Yes, I think it's the right thing to do.

changed the title [-]Dangerous reference count decrement.[/-] [+]`Python/instrumentation.c`: ensure non-NULL `PyLong_FromLong` results when possible[/+] on May 26, 2025
skv0zsneg

skv0zsneg commented on May 27, 2025

@skv0zsneg

Hi! I want to work on this issue but I didn't work with CPython at all. If it not a problem can you please provide some links for start?

grantlouisherman

grantlouisherman commented on May 30, 2025

@grantlouisherman

I think this can be closed because of #134415 right?

picnixz

picnixz commented on May 30, 2025

@picnixz
Member

It'll be closed once we merged the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    easyinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      `Python/instrumentation.c`: ensure non-NULL `PyLong_FromLong` results when possible · Issue #134411 · python/cpython

      Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

      Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant