Skip to content

Conversation

@krushnarout
Copy link
Member

@krushnarout krushnarout commented Dec 16, 2025

Line of code, what is the cause that leads to this fix? Which variable is potentially null?

var pd = await _device!.getDeviceInfo(connection);

var pd = await _device!.getDeviceInfo(connection);

crash occurs because _device can become null after await, for example when the device disconnects, but the code still uses _device!

closes #3804

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively resolves a critical null-pointer exception by adopting safer patterns for handling nullable class members in asynchronous methods. By caching the _device object in a local variable within SDCardWalSync and FlashPageWalSync, the code is now protected against race conditions where the device could be nulled after a check. Furthermore, the addition of null checks for the connection object returned by ensureConnection enhances the robustness of the connection handling logic. The changes are clean, correct, and consistently applied, representing a solid improvement to the codebase's stability.

@beastoin
Copy link
Collaborator

#3802 (comment)

@beastoin beastoin closed this Dec 17, 2025
@krushnarout krushnarout reopened this Dec 17, 2025
@krushnarout
Copy link
Member Author

krushnarout commented Dec 17, 2025

#3802 (comment)

done #3805 (comment)

@beastoin
Copy link
Collaborator

lgtm @krushnarout

@aaravgarg aaravgarg merged commit 5aa684f into main Dec 28, 2025
1 check passed
@aaravgarg aaravgarg deleted the fix/null-crash-3804 branch December 28, 2025 08:58
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.

FlutterError - Null check operator used on a null value - _getMissingWals

4 participants