Skip to content

Fix Device ENDRESTORE to not delete existing objects until after the first record is decoded - #1352

Merged
skarg merged 1 commit into
masterfrom
bugfix/reinitialize-device-ENDRESTORE-empty-restore-file
May 18, 2026
Merged

Fix Device ENDRESTORE to not delete existing objects until after the first record is decoded#1352
skarg merged 1 commit into
masterfrom
bugfix/reinitialize-device-ENDRESTORE-empty-restore-file

Conversation

@skarg

@skarg skarg commented May 18, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes Device_End_Restore so existing objects aren't deleted until the backup file's first record is successfully decoded, preventing data loss when the backup is empty or corrupt.

Changes:

  • Move the Device_Delete_Objects() call from before the decode loop to inside the loop, gated by offset == 0 and a successful decode.
  • Apply the same change in both device.c and bacnet_device.c implementations.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/bacnet/basic/server/bacnet_device.c Defer Device_Delete_Objects() until after first record decode succeeds.
src/bacnet/basic/object/device.c Same deferred-delete fix in the alternate Device implementation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@skarg
skarg merged commit e66dc72 into master May 18, 2026
40 checks passed
@skarg
skarg deleted the bugfix/reinitialize-device-ENDRESTORE-empty-restore-file branch May 18, 2026 19:49
skarg added a commit that referenced this pull request May 26, 2026
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