RobLoach / RobLoach/raylib-cpp
Model default constructor does not initialize base Model structure members
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 960
- Forks
- 120
- Avg merge
- 10m
- Merged PRs (30d)
- 1
Description
I've found that raylib::Model class is deraived from ::Model structure.
Whe you instantiate raylib::Model with default constructor no any members of ::Model is initialized, under Visual Studio you got all of members filled with some debug non zero values.
When you try to call ~Model destructor you will try to free memory by invalid pointer.
This Code inserted anywhere in main will cause an error:
{
raylib::Model model;
// You'll get an exception on block exit
}
Very quick fix - add base structure initialization like this:
/**
* Model type
*/
class Model : public ::Model {
public:
Model() : ::Model{}
{
// Nothing.
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the raylib::Model default constructor shown in the issue and inspect how it derives from ::Model. Reproduce the provided local-scope example under Visual Studio, then verify that destroying a default-constructed model no longer attempts to free invalid pointers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100