Merge lp:~aacid/qtubuntu/make_sure_mimedata_is_good into lp:qtubuntu

Proposed by Albert Astals Cid
Status: Merged
Approved by: Daniel d'Andrada
Approved revision: 373
Merged at revision: 376
Proposed branch: lp:~aacid/qtubuntu/make_sure_mimedata_is_good
Merge into: lp:qtubuntu
Diff against target: 15 lines (+1/-2)
1 file modified
src/ubuntumirclient/qmirclientclipboard.cpp (+1/-2)
To merge this branch: bzr merge lp:~aacid/qtubuntu/make_sure_mimedata_is_good
Reviewer Review Type Date Requested Status
Unity8 CI Bot continuous-integration Approve
Daniel d'Andrada (community) Approve
Review via email: mp+318641@code.launchpad.net

Commit message

Make sure mMimeData doesn't point to already deleted memory

QMirClientClipboard::mimeData(QClipboard::Mode mode) calls updateMimeData() and then returns mMimeData

Given that updateMimeData() can end up deleting the data in mMimeData but not always resetting the pointer we may end up returning a pointer that points to garbage

Description of the change

 * Are there any related MPs required for this MP to build/function as expected?
No

 * Did you perform an exploratory manual test run of your code change and any related functionality?
Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:372
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-ci/192/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/4271
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/4299
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4133
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4133/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4133
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4133/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4133
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4133/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4133
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4133/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4133
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4133/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4133
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4133/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-ci/192/rebuild

review: Approve (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Why don't we put the "delete mMimeData" inside the "if (focusWindow)" instead? That way we keep the old data until we're able to update it.

Revision history for this message
Albert Astals Cid (aacid) wrote :

> Why don't we put the "delete mMimeData" inside the "if (focusWindow)" instead?
> That way we keep the old data until we're able to update it.

I've the feeling that it makes more sense to return nothing if there's nothing on the clipboard than old stuff, but I have not much field expertize.

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

We don't know if there's nothing on the clipboard as weren't able to fetch it in the first place due to content-hub security restrictions (which require requestor to be focused at the moment of request)

Revision history for this message
Albert Astals Cid (aacid) wrote :

> We don't know if there's nothing on the clipboard as weren't able to fetch it in the first place
> due to content-hub security restrictions (which require requestor to be focused at the moment of
> request)

Shouldn't that be checked in contentHub and not in qtubuntu?

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> > We don't know if there's nothing on the clipboard as weren't able to fetch
> it in the first place
> > due to content-hub security restrictions (which require requestor to be
> focused at the moment of
> > request)
>
> Shouldn't that be checked in contentHub and not in qtubuntu?

contentHub does check it. qtubuntu just doesn't bother making the request when it knows it will fail.

373. By Albert Astals Cid

Daniel prefers this

Revision history for this message
Albert Astals Cid (aacid) wrote :

> Why don't we put the "delete mMimeData" inside the "if (focusWindow)" instead?
> That way we keep the old data until we're able to update it.

Ok

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

thanks

review: Approve
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:373
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-ci/194/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/4280
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/4308
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4142
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4142/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4142
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4142/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4142
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4142/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4142
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4142/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4142
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4142/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4142
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4142/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-ci/194/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ubuntumirclient/qmirclientclipboard.cpp'
2--- src/ubuntumirclient/qmirclientclipboard.cpp 2017-02-07 15:37:20 +0000
3+++ src/ubuntumirclient/qmirclientclipboard.cpp 2017-03-02 10:49:39 +0000
4@@ -141,10 +141,9 @@
5 return;
6 }
7
8- delete mMimeData;
9-
10 QWindow *focusWindow = QGuiApplication::focusWindow();
11 if (focusWindow) {
12+ delete mMimeData;
13 QString surfaceId = static_cast<QMirClientWindow*>(focusWindow->handle())->persistentSurfaceId();
14 mMimeData = mContentHub->latestPaste(surfaceId);
15 mClipboardState = SyncedClipboard;

Subscribers

People subscribed via source and target branches