Skip to content

Make Entry::m_tmpHistoryItem a QScopedPointer#2524

Merged
droidmonkey merged 3 commits intokeepassxreboot:developfrom
c4rlo:entry-dtor
Dec 1, 2018
Merged

Make Entry::m_tmpHistoryItem a QScopedPointer#2524
droidmonkey merged 3 commits intokeepassxreboot:developfrom
c4rlo:entry-dtor

Conversation

@c4rlo
Copy link
Copy Markdown
Contributor

@c4rlo c4rlo commented Dec 1, 2018

Type of change

  • ✅ Bug fix (non-breaking change which fixes an issue)

Description and Context

Most of the time, m_tmpHistoryItem should be null by the time an Entry is destroyed. However, if a caller ever calls beginUpdate() without later calling endUpdate() -- perhaps because an exception was throw in the meantime -- it may not be null.

This change avoids a memory leak in that case.

Found via https://lgtm.com/projects/g/keepassxreboot/keepassxc/alerts

Testing strategy

make test continues to pass.

Checklist:

  • ✅ I have read the CONTRIBUTING document. [REQUIRED]
  • ✅ My code follows the code style of this project. [REQUIRED]
  • ✅ All new and existing tests passed. [REQUIRED]
  • ✅ I have compiled and verified my code with -DWITH_ASAN=ON. [REQUIRED]

Most of the time, `m_tmpHistoryItem` should be null by the time an
`Entry` is destroyed. However, if a caller ever calls `beginUpdate()`
without later calling `endUpdate()` -- perhaps because an exception was
throw in the meantime -- it may not be null.

This change avoids a memory leak in that case.

Found via https://lgtm.com/projects/g/keepassxreboot/keepassxc/alerts
@droidmonkey
Copy link
Copy Markdown
Member

droidmonkey commented Dec 1, 2018

I would personally prefer this be changed to a QScopedPointer. We have a couple of crashes that surround history items. The whole history process needs a good refactor.

@c4rlo
Copy link
Copy Markdown
Contributor Author

c4rlo commented Dec 1, 2018

That sounds even better -- I'll look into that.

@c4rlo
Copy link
Copy Markdown
Contributor Author

c4rlo commented Dec 1, 2018

Would you be open to using std::unique_ptr instead of QScopedPointer? I ask because QScopedPointer is not move-constructable, and therefore cannot be put into any container. But it would be nice to make not only m_tmpHistoryItem a managed pointer, but also the contents of m_history, which is currently of type QList<Entry*>.

I realize that this goes against the conventions in this project (e.g. see #1213 (comment)). However, maybe it's time to revisit this?

@c4rlo
Copy link
Copy Markdown
Contributor Author

c4rlo commented Dec 1, 2018

Regardless of my above suggestion, I've now updated this PR to make just m_tmpHistoryItem a QScopedPointer. No need to touch m_history for now.

@c4rlo c4rlo changed the title Entry: delete m_tmpHistoryItem in destructor Make Entry::m_tmpHistoryItem a QScopedPointer Dec 1, 2018
@droidmonkey
Copy link
Copy Markdown
Member

In containers you use QSharedPointer

, m_autoTypeAssociations(new AutoTypeAssociations(this))
, m_customData(new CustomData(this))
, m_tmpHistoryItem(nullptr)
, m_tmpHistoryItem()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No need to initialize this

@droidmonkey droidmonkey merged commit bdee748 into keepassxreboot:develop Dec 1, 2018
sebastianlivoni added a commit to sebastianlivoni/keepassxc that referenced this pull request Jun 7, 2025
…9f734c..7943959d7

7943959d7 Merge pull request keepassxreboot#1 from sebastianlivoni/develop
42ba9be92 Merge branch 'feature/safari' into develop
003feb7c5 Merge pull request keepassxreboot#2571 from keepassxreboot/fix/check_input_width_with_segmented_totp
633fd4bf0 Merge pull request keepassxreboot#2574 from keepassxreboot/fix/atlassian_password_input
606e35762 Fix detecting Atlassian password input
eb9285212 Fix checking input width with segmented TOTP fields
dac9cecef Merge pull request keepassxreboot#2566 from keepassxreboot/fix/query_form_on_savedform_check
6b427faf3 Query form on savedForms check
54f5fe616 Merge pull request keepassxreboot#2560 from keepassxreboot/fix/update_issue_template
cda5ee592 Merge pull request keepassxreboot#2553 from keepassxreboot/fix/styling_improvements
8c42d7fce Add some more space between options
2c639749c Styling improvements
951557d50 Merge pull request keepassxreboot#2548 from joetor5/html-id
4be2b176c Fix browser integration doc link id
86c17bf04 Merge pull request keepassxreboot#2542 from keepassxreboot/fix/chatgpt_submit_button
8e4b866f4 Add submit button exception for OpenAI login page
a2748198b Merge pull request keepassxreboot#2525 from keepassxreboot/fix/credential_banner_improvement
064d27bf0 Improve username input detection with Credential Banner
dccf307e0 Merge pull request keepassxreboot#2524 from keepassxreboot/feature/add_support_for_firefox_shortcuts_page
c282d11ac Add support for opening Firefox shortcut settings page
5a6d37acf Merge pull request keepassxreboot#2523 from keepassxreboot/fix/get_credentials_from_different_db
7839dfe09 Fix retrieving credentials from changed DB in unlock dialog
25e1b2745 Merge pull request keepassxreboot#2522 from keepassxreboot/update_to_198
2bf48c680 Update to 1.9.8
0de621f0d Merge pull request keepassxreboot#2510 from keepassxreboot/fix/page_id_checks
d5063a6cf Fixes for page object checks and context menu item creation
a8297aeb5 Merge pull request keepassxreboot#2500 from keepassxreboot/fix/disable_passkeys_if_site_is_ignored
a5e7444f3 Merge pull request keepassxreboot#2521 from keepassxreboot/feature/support_autocomplete_username
f19c90cc0 Add support for autocomplete=username
e11d63df5 Disable passkeys script injection if site is ignored

git-subtree-dir: src/safariwebextension/keepassxc-browser
git-subtree-split: 7943959d7bb61a900f900b0a633778ea2acefa83
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