Skip to content

Fix handle leak #36184

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

Merged
merged 1 commit into from
Jun 6, 2025
Merged

Fix handle leak #36184

merged 1 commit into from
Jun 6, 2025

Conversation

cincuranet
Copy link
Contributor

Fixes #35010

@cincuranet
Copy link
Contributor Author

cincuranet commented Jun 4, 2025

FYI, based on Copilot implementation from #36176.

@cincuranet cincuranet requested review from a team and Copilot June 4, 2025 14:17
@cincuranet cincuranet marked this pull request as ready for review June 4, 2025 14:17
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a handle leak issue by ensuring that a database handle is properly released when the SqliteConnectionInternal constructor fails during password decryption.

  • Adds a new test to verify that a failed constructor call releases its handle.
  • Wraps the critical initialization code in a try–catch block and disposes the handle if an exception is thrown.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
test/Microsoft.Data.Sqlite.Tests/SqliteConnectionTest.cs Adds test case for ensuring handle release on constructor failure
src/Microsoft.Data.Sqlite.Core/SqliteConnectionInternal.cs Implements try–catch to dispose the handle in case of constructor failure

@cincuranet cincuranet merged commit 8a8e758 into dotnet:main Jun 6, 2025
7 checks passed
@cincuranet cincuranet deleted the handle-leak branch June 6, 2025 06:38
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.

Microsoft.Data.Sqlite keeps handle on file even after close, and pool clear
2 participants