Skip to content

Feat/project modernization#906

Merged
codeHusky merged 16 commits intosmartcmd:mainfrom
ModMaker101:feat/project-modernization
Mar 8, 2026
Merged

Feat/project modernization#906
codeHusky merged 16 commits intosmartcmd:mainfrom
ModMaker101:feat/project-modernization

Conversation

@ModMaker101
Copy link
Contributor

Description

Adds checks to prevent std::vector out of range access and null pointer dereferences that causes runtime assertions which caused a crash in my last PR.

Changes

Previous Behavior

Some rendering and UI code assumed pointers and vectors indices were always valid. In certain cases this cause the MSVC crash/assertion 'vector subscript out of range`.

Root Cause

  • Reverse loops using size_t could underflow when decrementing past 0.
  • Missing bounds checks when accessing vectors.
  • Missing null checks for objects.

New Behavior

The code now validates indices and pointers before use, preventing invalid vector access and null dereferences.

Fix Implementation

  • Replaced reverse loops using size_T with int to avoid unsinged underflow.
  • Added null checks before using objects.
  • Added bounds checks before accessing container slots.

AI Use Disclosure

No.

Related Issues/PR

@codeHusky Sorry about not testing it totally cross my mind while I was doing it, because I was just confident in my code which was a rookie mistake. But I tested this one and it was working just fine so if you could review this one.

@ModMaker101
Copy link
Contributor Author

2026-03-07.23-42-01.mp4

@codeHusky
Copy link
Collaborator

Tests okay for me (multiplayer, world gen, etc), merging!

@codeHusky codeHusky merged commit 28614b9 into smartcmd:main Mar 8, 2026
1 check passed
piebotc pushed a commit to piebotc/LegacyEvolved that referenced this pull request Mar 9, 2026
* Fixed boats falling and a TP glitch smartcmd#266

* Replaced every C-style cast with C++ ones

* Replaced every C-style cast with C++ ones

* Fixed boats falling and a TP glitch smartcmd#266

* Updated NULL to nullptr and fixing some type issues

* Modernized and fixed a few bugs

- Replaced most instances of `NULL` with `nullptr`.
- Replaced most `shared_ptr(new ...)` with `make_shared`.
- Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances.

* Fixing more conflicts

* Replace int loops with size_t and start work on overrides

* Add safety checks and fix a issue with vector going OOR
Kamenkovic pushed a commit to Kamenkovic/FpsLimit that referenced this pull request Mar 9, 2026
* Fixed boats falling and a TP glitch smartcmd#266

* Replaced every C-style cast with C++ ones

* Replaced every C-style cast with C++ ones

* Fixed boats falling and a TP glitch smartcmd#266

* Updated NULL to nullptr and fixing some type issues

* Modernized and fixed a few bugs

- Replaced most instances of `NULL` with `nullptr`.
- Replaced most `shared_ptr(new ...)` with `make_shared`.
- Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances.

* Fixing more conflicts

* Replace int loops with size_t and start work on overrides

* Add safety checks and fix a issue with vector going OOR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants