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

Fix dangling reference #10135

Merged

Conversation

dmaslenko
Copy link
Contributor

@dmaslenko dmaslenko commented Dec 29, 2023

Fixes compilation error: dangling reference #10134

Screenshots

N/A

Testing strategy

The build was tested locally by the commands:

cd build
cmake -DWITH_XC_ALL=ON -DCMAKE_BUILD_TYPE=Debug -DWITH_TESTS=ON -DWITH_GUI_TESTS=ON ..
make -j8

Type of change

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

[What]
  Refactor the Remove.cpp to use a local variable for
  positionalArguments() return.

[Why]
  To fix the compilation issue:
    error: possibly dangling reference to a temporary

  The parser->positionalArguments() function returns a
  temporary QList object, and at(1) returns a reference
  to an element in that list.

  But the temporary QList object is destroyed after this
  line of code, leaving entryPath to be a dangling reference.
The previous code assigned entryPath in two steps, first by getting the
positional arguments from the parser, and then by selecting the second argument.
This was modified to a single-line assignment for better readability and code simplicity.
@droidmonkey droidmonkey merged commit 5d64292 into keepassxreboot:develop Jan 6, 2024
2 checks passed
@dmaslenko dmaslenko deleted the fix_dangling_reference branch January 7, 2024 06:02
@droidmonkey droidmonkey added the pr: backported Pull request backported to previous release label Jan 27, 2024
droidmonkey pushed a commit that referenced this pull request Jan 27, 2024
@phoerious phoerious added pr: bugfix Pull request that fixes a bug and removed bug labels Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build system pr: backported Pull request backported to previous release pr: bugfix Pull request that fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants