Skip to content

Fix infinite loop when adding a column to an existing primary key - #4217

Open
deepsidhu1313 wants to merge 1 commit into
sqlitebrowser:masterfrom
deepsidhu1313:fix/composite-pk-freeze
Open

deepsidhu1313 wants to merge 1 commit into
sqlitebrowser:masterfrom
deepsidhu1313:fix/composite-pk-freeze

Conversation

@deepsidhu1313

Copy link
Copy Markdown
Contributor

Table::addKeyToConstraint() inserts the extended constraint into the
multimap while iterating over it. The column list [a,b] sorts after [a], so
the loop finds the same constraint again and extends it forever, which
froze the application and ended in a bad_alloc when ticking a second
primary key checkbox in the Edit Table dialog. removeKeyFromConstraint()
has the same pattern. A constraint object is only stored once, so stop
after updating it.

A new unit test covers adding and removing keys; it hangs without this
fix.

Fixes #4150

Table::addKeyToConstraint() inserts the extended constraint into the
multimap while iterating over it. The column list [a,b] sorts after [a], so
the loop finds the same constraint again and extends it forever, which
froze the application and ended in a bad_alloc when ticking a second
primary key checkbox in the Edit Table dialog. removeKeyFromConstraint()
has the same pattern. A constraint object is only stored once, so stop
after updating it.

A new unit test covers adding and removing keys; it hangs without this
fix.

Fixes sqlitebrowser#4150

This branch has not been deployed

No deployments
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.

[Bug]: Freeze when adding composite key with checkboxes

2 participants