Skip to content

Potential fix for code scanning alert no. 355: Redundant null check due to previous dereference - #937

Draft
matteius wants to merge 2 commits into
mainfrom
alert-autofix-355
Draft

matteius wants to merge 2 commits into
mainfrom
alert-autofix-355

Conversation

@matteius

@matteius matteius commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Potential fix for https://github.com/opensensor/lightNVR/security/code-scanning/355

General fix approach: when a pointer is validated/dereferenced earlier in the same control flow, avoid repeating null checks later. Either move checks before first dereference, or remove later redundant checks.

Best fix here (no functionality change): in src/core/observation_retention.c, inside remove_asset_file, replace:

  • if (stored && *stored) log_warn(...);

with an unconditional log_warn(...), because reaching that block already implies stored is non-null and non-empty due to line 124 early return.

No imports, new methods, or new definitions are needed.

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

…ue to previous dereference

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@codecov

codecov Bot commented Nov 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Generated by tools/rust-transpile/generate.py for 3f473bf.
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