Skip to content

canbus: clear interface pointer after free - #5

Open
Opriego wants to merge 1 commit into
jeremyhahn:masterfrom
Opriego:fix/canbus-free-null-assignment
Open

canbus: clear interface pointer after free#5
Opriego wants to merge 1 commit into
jeremyhahn:masterfrom
Opriego:fix/canbus-free-null-assignment

Conversation

@Opriego

@Opriego Opriego commented Aug 17, 2026

Copy link
Copy Markdown

Summary

  • add a focused regression test for canbus_free
  • clear canbus->iface after freeing it

Problem

canbus_free uses the equality operator instead of assignment after freeing
canbus->iface. The expression has no effect, leaving a dangling pointer in the
client structure.

Fix

Replace the ineffective comparison with an assignment to NULL.

Testing

Before the fix:

0%: Checks: 1, Failures: 1, Errors: 0
Assertion 'client.iface == NULL' failed

After the fix:

100%: Checks: 1, Failures: 0, Errors: 0

The existing canbus_shutdown pointer/integer comparison warning is unrelated
and remains unchanged.

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