Skip to content

Potential fix for code scanning alert no. 5574: Dereferenced variable is always null#12

Merged
ChristianRosewich merged 1 commit into
masterfrom
alert-autofix-2
Jul 14, 2026
Merged

Potential fix for code scanning alert no. 5574: Dereferenced variable is always null#12
ChristianRosewich merged 1 commit into
masterfrom
alert-autofix-2

Conversation

@ChristianRosewich

Copy link
Copy Markdown
Owner

Potential fix for https://github.com/ChristianRosewich/CSharp/security/code-scanning/5574

To fix this safely without changing behavior, replace the null-prone comparison on line 907:

  • from: dB_EventTable.Fields[EventFields.Art].AsEnum<EEventArt>() == text.AsEnum<EEventArt>()
  • to: dB_EventTable.Fields[EventFields.Art].AsEnum<EEventArt>() == eArt

This is the best fix because:

  • it removes a guaranteed-null dereference risk,
  • it uses the already-available strongly typed enum variable (eArt) that is already used for the indexed seek in the same block,
  • it preserves intended filtering logic (match current record art to selected eArt).

Also remove the now-unused text declaration at line 806 to keep the method clean and avoid warnings.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

… is always null

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@ChristianRosewich ChristianRosewich marked this pull request as ready for review July 14, 2026 12:24
@ChristianRosewich ChristianRosewich merged commit 80b1fee into master Jul 14, 2026
1 of 3 checks passed
@ChristianRosewich ChristianRosewich deleted the alert-autofix-2 branch July 14, 2026 12:24
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.

1 participant