Merge lp:~ted/ubuntu-app-launch/primary-pid-no-app into lp:ubuntu-app-launch/16.10

Proposed by Ted Gould
Status: Merged
Approved by: dobey
Approved revision: 246
Merged at revision: 246
Proposed branch: lp:~ted/ubuntu-app-launch/primary-pid-no-app
Merge into: lp:ubuntu-app-launch/16.10
Diff against target: 61 lines (+7/-5)
2 files modified
libubuntu-app-launch/ubuntu-app-launch.cpp (+5/-5)
tests/libual-test.cc (+2/-0)
To merge this branch: bzr merge lp:~ted/ubuntu-app-launch/primary-pid-no-app
Reviewer Review Type Date Requested Status
unity-api-1-bot continuous-integration Needs Fixing
dobey (community) Approve
Review via email: mp+303940@code.launchpad.net

Commit message

Use at() instead of operator[]() so that we get an exception on bounds checking

Description of the change

Didn't realize that vector's operator[]() doesn't do any bounds checking and it just crashes. Which is stupid, but supported by the documentation. Switching to use at() that does do bounds checking and throws an exception that we can catch as we'd expected.

To post a comment you must log in.
Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

FAILED: Continuous integration, rev:246
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntu-app-launch-ci/69/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build/487/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/493
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=vivid+overlay/398
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=xenial+overlay/398
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=yakkety/398
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/328/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/328
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/328/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/328
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/328/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/328/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/328
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/328/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/328
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/328/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/328/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/328
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/328/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/328
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/328/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntu-app-launch-ci/69/rebuild

review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libubuntu-app-launch/ubuntu-app-launch.cpp'
--- libubuntu-app-launch/ubuntu-app-launch.cpp 2016-08-04 15:04:04 +0000
+++ libubuntu-app-launch/ubuntu-app-launch.cpp 2016-08-25 14:25:42 +0000
@@ -465,7 +465,7 @@
465 auto registry = ubuntu::app_launch::Registry::getDefault();465 auto registry = ubuntu::app_launch::Registry::getDefault();
466 auto appId = ubuntu::app_launch::AppID::find(appid);466 auto appId = ubuntu::app_launch::AppID::find(appid);
467 auto app = ubuntu::app_launch::Application::create(appId, registry);467 auto app = ubuntu::app_launch::Application::create(appId, registry);
468 app->instances()[0]->pause();468 app->instances().at(0)->pause();
469 return TRUE;469 return TRUE;
470 } catch (...) {470 } catch (...) {
471 return FALSE;471 return FALSE;
@@ -479,7 +479,7 @@
479 auto registry = ubuntu::app_launch::Registry::getDefault();479 auto registry = ubuntu::app_launch::Registry::getDefault();
480 auto appId = ubuntu::app_launch::AppID::find(appid);480 auto appId = ubuntu::app_launch::AppID::find(appid);
481 auto app = ubuntu::app_launch::Application::create(appId, registry);481 auto app = ubuntu::app_launch::Application::create(appId, registry);
482 app->instances()[0]->resume();482 app->instances().at(0)->resume();
483 return TRUE;483 return TRUE;
484 } catch (...) {484 } catch (...) {
485 return FALSE;485 return FALSE;
@@ -1211,7 +1211,7 @@
1211 auto registry = std::make_shared<ubuntu::app_launch::Registry>();1211 auto registry = std::make_shared<ubuntu::app_launch::Registry>();
1212 auto appId = ubuntu::app_launch::AppID::find(appid);1212 auto appId = ubuntu::app_launch::AppID::find(appid);
1213 auto app = ubuntu::app_launch::Application::create(appId, registry);1213 auto app = ubuntu::app_launch::Application::create(appId, registry);
1214 return app->instances()[0]->primaryPid();1214 return app->instances().at(0)->primaryPid();
1215 } catch (...) {1215 } catch (...) {
1216 return 0;1216 return 0;
1217 }1217 }
@@ -1227,7 +1227,7 @@
1227 auto registry = std::make_shared<ubuntu::app_launch::Registry>();1227 auto registry = std::make_shared<ubuntu::app_launch::Registry>();
1228 auto appId = ubuntu::app_launch::AppID::find(appid);1228 auto appId = ubuntu::app_launch::AppID::find(appid);
1229 auto app = ubuntu::app_launch::Application::create(appId, registry);1229 auto app = ubuntu::app_launch::Application::create(appId, registry);
1230 auto pids = app->instances()[0]->pids();1230 auto pids = app->instances().at(0)->pids();
12311231
1232 GList * retval = nullptr;1232 GList * retval = nullptr;
1233 for (auto pid : pids) {1233 for (auto pid : pids) {
@@ -1249,7 +1249,7 @@
1249 auto appId = ubuntu::app_launch::AppID::find(appid);1249 auto appId = ubuntu::app_launch::AppID::find(appid);
1250 auto app = ubuntu::app_launch::Application::create(appId, registry);1250 auto app = ubuntu::app_launch::Application::create(appId, registry);
12511251
1252 if (app->instances()[0]->hasPid(pid)) {1252 if (app->instances().at(0)->hasPid(pid)) {
1253 return TRUE;1253 return TRUE;
1254 } else {1254 } else {
1255 return FALSE;1255 return FALSE;
12561256
=== modified file 'tests/libual-test.cc'
--- tests/libual-test.cc 2016-08-17 13:17:08 +0000
+++ tests/libual-test.cc 2016-08-25 14:25:42 +0000
@@ -509,6 +509,8 @@
509 EXPECT_TRUE(g_variant_equal(calls->params, g_variant_new("(ss)", "freezer", "upstart/application-legacy-multiple-2342345")));509 EXPECT_TRUE(g_variant_equal(calls->params, g_variant_new("(ss)", "freezer", "upstart/application-legacy-multiple-2342345")));
510 ASSERT_TRUE(dbus_test_dbus_mock_object_clear_method_calls(cgmock, cgobject, NULL));510 ASSERT_TRUE(dbus_test_dbus_mock_object_clear_method_calls(cgmock, cgobject, NULL));
511511
512 /* Check non running app */
513 EXPECT_EQ(0, ubuntu_app_launch_get_primary_pid("chatter.robert-ancell_chatter_2"));
512}514}
513515
514TEST_F(LibUAL, ApplicationId)516TEST_F(LibUAL, ApplicationId)

Subscribers

People subscribed via source and target branches