Skip to content

Almost all operator[](int64_t p_index) can return null pointer reference #1948

@NoctemCat

Description

@NoctemCat

Godot version

master

godot-cpp version

master

System information

linux

Issue description

Seems like godot-cpp relied on a native error logging before, but it was removed in godotengine/godot#66185 , and instead index operators now silently return nullptr. godot-cpp doesn't check for it and can silently dereference it, so the next time you access it, it will crash. I think this affects all arrays, both normal and packed. And also String... dictionary seems fine so far.

I guess this just needs a better error message and/or crash at this place specifically. As it's really unexpected to silently return invalid reference to nullptr, because this in itself won't cause a crash, but the next access to any of its member will.

Steps to reproduce

Use [] to access any element outside of valid range.

Minimal reproduction project

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions