Skip to content
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

Delay creation of EnchantDict to avoid partial initialization in AppleSpell provider #399

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nossralf
Copy link

@nossralf nossralf commented Nov 3, 2024

To properly destruct an EnchantDict, its session field must be non-null since the destructor assumes a session has been associated with the object. This association happens in EnchantBroker when a provider upon request finds a valid dictionary and in doing so creates an EnchantDict object which is returned to the broker.

In the AppleSpell provider, the EnchantDict was created regardless of whether the provider would be able to find a valid dictionary or not. If it did not find a valid dictionary, it would erroneously free the EnchantDict object and return null, despite the leaving the EnchantDict in the broker's set of dictionaries.

This commit fixes the issue by moving the creation of the EnchantDict to occur after successfully finding a valid dictionary.

Fixes #391

To properly destruct an EnchantDict, its session field must be non-null since
the destructor assumes a session has been associated with the object. This
association happens in EnchantBroker when a provider upon request finds a valid
dictionary and in doing so creates an EnchantDict object which is returned to
the broker.

In the AppleSpell provider, the EnchantDict was created regardless of whether
the provider would be able to find a valid dictionary or not. If it did not
find a valid dictionary, it would erroneously free the EnchantDict object and
return null, despite the leaving the EnchantDict in the broker's set of
dictionaries.

This commit fixes the issue by moving the creation of the EnchantDict to occur
after successfully finding a valid dictionary.

Fixes rrthomas#391
@nossralf nossralf changed the title Delay creation of EnchantDict to avoid partial initialization Delay creation of EnchantDict to avoid partial initialization in AppleSpell provider Nov 3, 2024
@rrthomas
Copy link
Owner

rrthomas commented Nov 3, 2024

Thanks very much for looking into this, and I'll review ASAP.

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.

brew-installed on mac intermittently segfaults
2 participants