Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add null check for moveFunction to prevent crashes #3213

Merged
merged 2 commits into from
Jan 5, 2025

Conversation

dudantas
Copy link
Member

@dudantas dudantas commented Jan 4, 2025

Description

This PR adds a null check for the moveFunction in the MoveEvent::fireAddRemItem method. Previously, the code accessed moveFunction directly without verifying its validity, which could lead to crashes if it was nullptr. The fix ensures stability by:

  • Logging an error message when moveFunction is null.
  • Returning early to prevent further execution with an invalid function pointer.

This change improves the reliability of the function, particularly in scenarios where moveFunction might not be properly initialized.


Behaviour

Actual

  • Accessing moveFunction without checking if it is null could lead to crashes when it was uninitialized or invalid.

Expected

  • If moveFunction is null, the code logs an error and exits early, preventing crashes.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested

  • Simulated scenarios where moveFunction is null to ensure the error is logged and execution stops without crashing.
  • Tested scenarios with valid moveFunction to confirm expected behavior is preserved.

Checklist

  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • I checked the PR checks reports.
  • I have commented my code, particularly in hard-to-understand areas.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.

Sorry, something went wrong.

Copy link
Contributor

@FelipePaluco FelipePaluco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@majestyotbr majestyotbr merged commit 3471783 into main Jan 5, 2025
21 of 24 checks passed
@majestyotbr majestyotbr deleted the dudantas/fix-fire-add-rem-item-crash branch January 5, 2025 00:02
Copy link

sonarqubecloud bot commented Jan 5, 2025

vllworldbuilding pushed a commit to vllworldbuilding/canary that referenced this pull request Jan 10, 2025
…3213)

This adds a null check for the moveFunction in the MoveEvent::fireAddRemItem method. Previously, the code accessed moveFunction directly without verifying its validity, which could lead to crashes if it was nullptr. The fix ensures stability by:

Logging an error message when moveFunction is null.
Returning early to prevent further execution with an invalid function pointer.
This change improves the reliability of the function, particularly in scenarios where moveFunction might not be properly initialized.
lucas-caminha pushed a commit to lucas-caminha/canary that referenced this pull request Jan 19, 2025
…3213)

This adds a null check for the moveFunction in the MoveEvent::fireAddRemItem method. Previously, the code accessed moveFunction directly without verifying its validity, which could lead to crashes if it was nullptr. The fix ensures stability by:

Logging an error message when moveFunction is null.
Returning early to prevent further execution with an invalid function pointer.
This change improves the reliability of the function, particularly in scenarios where moveFunction might not be properly initialized.
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.

None yet

4 participants