godotengine / godotengine/godot-cpp

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

Open
#1,948 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.7k
Forks
809
Avg merge
1d 3h
Merged PRs (30d)
8

Description

### 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 https://github.com/godotengine/godot/pull/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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.