{"action":"closed","number":448,"pull_request":{"url":"https://api.github.com/repos/connectbot/connectbot/pulls/448","id":93598301,"html_url":"https://github.com/connectbot/connectbot/pull/448","diff_url":"https://github.com/connectbot/connectbot/pull/448.diff","patch_url":"https://github.com/connectbot/connectbot/pull/448.patch","issue_url":"https://api.github.com/repos/connectbot/connectbot/issues/448","number":448,"state":"closed","locked":false,"title":"Fixed a possible resource leak linked to a SQL cursor","user":{"login":"perpetualjourney","id":5505342,"avatar_url":"https://avatars.githubusercontent.com/u/5505342?v=3","gravatar_id":"","url":"https://api.github.com/users/perpetualjourney","html_url":"https://github.com/perpetualjourney","followers_url":"https://api.github.com/users/perpetualjourney/followers","following_url":"https://api.github.com/users/perpetualjourney/following{/other_user}","gists_url":"https://api.github.com/users/perpetualjourney/gists{/gist_id}","starred_url":"https://api.github.com/users/perpetualjourney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/perpetualjourney/subscriptions","organizations_url":"https://api.github.com/users/perpetualjourney/orgs","repos_url":"https://api.github.com/users/perpetualjourney/repos","events_url":"https://api.github.com/users/perpetualjourney/events{/privacy}","received_events_url":"https://api.github.com/users/perpetualjourney/received_events","type":"User","site_admin":false},"body":"I was using [Infer](http://fbinfer.com) to check Android apps for bugs and found this in your codebase. There were 9 additional null dereference bugs but I think they may be false positives.\r\n\r\nPlease let me know if this is useful at all - I did not have the chance to run extensive testing of the changes.\r\n\r\nHere is the full output of running `infer -- ./gradlew assemble` on the master branch before the changes in this PR (notice the `RESOURCE_LEAK` problem now resolved):\r\n```\r\nFound 10 issues\r\n\r\napp/src/main/java/org/connectbot/ConsoleActivity.java:434: error: NULL_DEREFERENCE\r\n  object ConsoleActivity.actionBar last accessed on line 434 is annotated with @Nullable and is dereferenced without a null check at line 434\r\n  432.   \t\t}\r\n  433.   \t\tif (showActionBar) {\r\n  434. > \t\t\tactionBar.show();\r\n  435.   \t\t}\r\n  436.   \t\tautoHideEmulatedKeys();\r\n  437.\r\n\r\napp/src/main/java/org/connectbot/PubkeyListActivity.java:317: error: NULL_DEREFERENCE\r\n  object returned by keybean.getPrivateKey() could be null and is dereferenced by call to String(...) at line 317\r\n  315.   \t\t\t// load specific key using pem format\r\n  316.   \t\t\ttry {\r\n  317. > \t\t\t\tpair = PEMDecoder.decode(new String(keybean.getPrivateKey()).toCharArray(), password);\r\n  318.   \t\t\t} catch (Exception e) {\r\n  319.   \t\t\t\tString message = getResources().getString(R.string.pubkey_failed_add, keybean.getNickname());\r\n  320.\r\n\r\napp/src/main/java/org/connectbot/PubkeyListActivity.java:587: error: NULL_DEREFERENCE\r\n  object returned by PubkeyListActivity$PubkeyViewHolder$4.this$1.pubkey.getPrivateKey() could be null and is dereferenced by call to String(...) at line 587\r\n  585.   \t\t\t\t\t\tif (imported)\r\n  586.   \t\t\t\t\t\t\tdata = new String(pubkey.getPrivateKey());\r\n  587. > \t\t\t\t\t\telse {\r\n  588.   \t\t\t\t\t\t\tPrivateKey pk = PubkeyUtils.decodePrivate(pubkey.getPrivateKey(), pubkey.getType());\r\n  589.\r\n\r\napp/src/main/java/org/connectbot/PubkeyListActivity.java:736: error: NULL_DEREFERENCE\r\n  object returned by pubkey.getPrivateKey() could be null and is dereferenced by call to String(...) at line 736\r\n  734.   \t\t\tif (imported) {\r\n  735.   \t\t\t\ttry {\r\n  736. > \t\t\t\t\tPEMStructure struct = PEMDecoder.parsePEM(new String(pubkey.getPrivateKey()).toCharArray());\r\n  737.   \t\t\t\t\tString type;\r\n  738.   \t\t\t\t\tif (struct.pemType == PEMDecoder.PEM_RSA_PRIVATE_KEY) {\r\n  739.\r\n\r\napp/src/main/java/org/connectbot/TerminalView.java:644: error: RESOURCE_LEAK\r\n   resource of type android.database.sqlite.SQLiteCursor acquired to cursor by call to query(...) at line 641 is not released after line 644\r\n  642.   \t\t\t\t\t\tUri.parse(\"content://\" + screenReader.serviceInfo.packageName\r\n  643.   \t\t\t\t\t\t\t\t+ \".providers.StatusProvider\"), null, null, null, null);\r\n  644. > \t\t\t\tif (cursor != null && cursor.moveToFirst()) {\r\n  645.   \t\t\t\t\t/*\r\n  646.   \t\t\t\t\t * These content providers use a special cursor that only has\r\n  647.\r\n\r\napp/src/main/java/org/connectbot/bean/HostBean.java:342: error: NULL_DEREFERENCE\r\n  object returned by getTransport(HostBean.protocol) could be null and is dereferenced at line 342\r\n  340.   \t\t\treturn \"\";\r\n  341.\r\n  342. > \t\tint defaultPort = TransportFactory.getTransport(protocol).getDefaultPort();\r\n  343.\r\n  344.   \t\tif (SSH.getProtocolName().equals(protocol)) {\r\n  345.\r\n\r\napp/src/main/java/org/connectbot/service/TerminalBridge.java:160: error: NULL_DEREFERENCE\r\n  object TerminalBridge.manager last assigned on line 145 could be null and is dereferenced by call to TerminalKeyListener(...) at line 160\r\n  158.   \t\ttransport = null;\r\n  159.\r\n  160. > \t\tkeyListener = new TerminalKeyListener(manager, this, buffer, null);\r\n  161.   \t}\r\n  162.\r\n\r\napp/src/main/java/org/connectbot/service/TerminalBridge.java:266: error: NULL_DEREFERENCE\r\n  object TerminalBridge.transport last assigned on line 265 could be null and is dereferenced at line 266\r\n  264.   \tprotected void startConnection() {\r\n  265.   \t\ttransport = TransportFactory.getTransport(host.getProtocol());\r\n  266. > \t\ttransport.setBridge(this);\r\n  267.   \t\ttransport.setManager(manager);\r\n  268.   \t\ttransport.setHost(host);\r\n  269.\r\n\r\napp/src/main/java/org/connectbot/transport/SSH.java:358: error: NULL_DEREFERENCE\r\n  object returned by pubkey.getPrivateKey() could be null and is dereferenced by call to String(...) at line 358\r\n  356.   \t\t\tif (PubkeyDatabase.KEY_TYPE_IMPORTED.equals(pubkey.getType())) {\r\n  357.   \t\t\t\t// load specific key using pem format\r\n  358. > \t\t\t\tpair = PEMDecoder.decode(new String(pubkey.getPrivateKey()).toCharArray(), password);\r\n  359.   \t\t\t} else {\r\n  360.   \t\t\t\t// load using internal generated format\r\n  361.\r\n\r\napp/src/main/java/org/connectbot/transport/TransportFactory.java:122: error: NULL_DEREFERENCE\r\n  object transport last assigned on line 118 could be null and is dereferenced at line 122\r\n  120.   \t\tMap<String, String> selection = new HashMap<String, String>();\r\n  121.\r\n  122. > \t\ttransport.getSelectionArgs(uri, selection);\r\n  123.   \t\tif (selection.isEmpty()) {\r\n  124.   \t\t\tLog.e(TAG, String.format(\"Transport %s failed to do something useful with URI=%s\",\r\n  125.\r\n\r\nSummary of the reports\r\n\r\n  NULL_DEREFERENCE: 9\r\n     RESOURCE_LEAK: 1\r\n```","created_at":"2016-11-14T16:24:58Z","updated_at":"2016-11-19T05:52:42Z","closed_at":"2016-11-19T05:52:42Z","merged_at":"2016-11-19T05:52:42Z","merge_commit_sha":"626f79f35c1903612e4623a633a097f90fbb10df","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/connectbot/connectbot/pulls/448/commits","review_comments_url":"https://api.github.com/repos/connectbot/connectbot/pulls/448/comments","review_comment_url":"https://api.github.com/repos/connectbot/connectbot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/connectbot/connectbot/issues/448/comments","statuses_url":"https://api.github.com/repos/connectbot/connectbot/statuses/4ce1ed42ebd79224828d6bb1992c5d4beaf24999","head":{"label":"perpetualjourney:master","ref":"master","sha":"4ce1ed42ebd79224828d6bb1992c5d4beaf24999","user":{"login":"perpetualjourney","id":5505342,"avatar_url":"https://avatars.githubusercontent.com/u/5505342?v=3","gravatar_id":"","url":"https://api.github.com/users/perpetualjourney","html_url":"https://github.com/perpetualjourney","followers_url":"https://api.github.com/users/perpetualjourney/followers","following_url":"https://api.github.com/users/perpetualjourney/following{/other_user}","gists_url":"https://api.github.com/users/perpetualjourney/gists{/gist_id}","starred_url":"https://api.github.com/users/perpetualjourney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/perpetualjourney/subscriptions","organizations_url":"https://api.github.com/users/perpetualjourney/orgs","repos_url":"https://api.github.com/users/perpetualjourney/repos","events_url":"https://api.github.com/users/perpetualjourney/events{/privacy}","received_events_url":"https://api.github.com/users/perpetualjourney/received_events","type":"User","site_admin":false},"repo":{"id":73721604,"name":"connectbot","full_name":"perpetualjourney/connectbot","owner":{"login":"perpetualjourney","id":5505342,"avatar_url":"https://avatars.githubusercontent.com/u/5505342?v=3","gravatar_id":"","url":"https://api.github.com/users/perpetualjourney","html_url":"https://github.com/perpetualjourney","followers_url":"https://api.github.com/users/perpetualjourney/followers","following_url":"https://api.github.com/users/perpetualjourney/following{/other_user}","gists_url":"https://api.github.com/users/perpetualjourney/gists{/gist_id}","starred_url":"https://api.github.com/users/perpetualjourney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/perpetualjourney/subscriptions","organizations_url":"https://api.github.com/users/perpetualjourney/orgs","repos_url":"https://api.github.com/users/perpetualjourney/repos","events_url":"https://api.github.com/users/perpetualjourney/events{/privacy}","received_events_url":"https://api.github.com/users/perpetualjourney/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/perpetualjourney/connectbot","description":"ConnectBot is the first SSH client for Android.","fork":true,"url":"https://api.github.com/repos/perpetualjourney/connectbot","forks_url":"https://api.github.com/repos/perpetualjourney/connectbot/forks","keys_url":"https://api.github.com/repos/perpetualjourney/connectbot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/perpetualjourney/connectbot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/perpetualjourney/connectbot/teams","hooks_url":"https://api.github.com/repos/perpetualjourney/connectbot/hooks","issue_events_url":"https://api.github.com/repos/perpetualjourney/connectbot/issues/events{/number}","events_url":"https://api.github.com/repos/perpetualjourney/connectbot/events","assignees_url":"https://api.github.com/repos/perpetualjourney/connectbot/assignees{/user}","branches_url":"https://api.github.com/repos/perpetualjourney/connectbot/branches{/branch}","tags_url":"https://api.github.com/repos/perpetualjourney/connectbot/tags","blobs_url":"https://api.github.com/repos/perpetualjourney/connectbot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/perpetualjourney/connectbot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/perpetualjourney/connectbot/git/refs{/sha}","trees_url":"https://api.github.com/repos/perpetualjourney/connectbot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/perpetualjourney/connectbot/statuses/{sha}","languages_url":"https://api.github.com/repos/perpetualjourney/connectbot/languages","stargazers_url":"https://api.github.com/repos/perpetualjourney/connectbot/stargazers","contributors_url":"https://api.github.com/repos/perpetualjourney/connectbot/contributors","subscribers_url":"https://api.github.com/repos/perpetualjourney/connectbot/subscribers","subscription_url":"https://api.github.com/repos/perpetualjourney/connectbot/subscription","commits_url":"https://api.github.com/repos/perpetualjourney/connectbot/commits{/sha}","git_commits_url":"https://api.github.com/repos/perpetualjourney/connectbot/git/commits{/sha}","comments_url":"https://api.github.com/repos/perpetualjourney/connectbot/comments{/number}","issue_comment_url":"https://api.github.com/repos/perpetualjourney/connectbot/issues/comments{/number}","contents_url":"https://api.github.com/repos/perpetualjourney/connectbot/contents/{+path}","compare_url":"https://api.github.com/repos/perpetualjourney/connectbot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/perpetualjourney/connectbot/merges","archive_url":"https://api.github.com/repos/perpetualjourney/connectbot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/perpetualjourney/connectbot/downloads","issues_url":"https://api.github.com/repos/perpetualjourney/connectbot/issues{/number}","pulls_url":"https://api.github.com/repos/perpetualjourney/connectbot/pulls{/number}","milestones_url":"https://api.github.com/repos/perpetualjourney/connectbot/milestones{/number}","notifications_url":"https://api.github.com/repos/perpetualjourney/connectbot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/perpetualjourney/connectbot/labels{/name}","releases_url":"https://api.github.com/repos/perpetualjourney/connectbot/releases{/id}","deployments_url":"https://api.github.com/repos/perpetualjourney/connectbot/deployments","created_at":"2016-11-14T15:57:57Z","updated_at":"2016-11-14T15:58:00Z","pushed_at":"2016-11-18T12:05:20Z","git_url":"git://github.com/perpetualjourney/connectbot.git","ssh_url":"git@github.com:perpetualjourney/connectbot.git","clone_url":"https://github.com/perpetualjourney/connectbot.git","svn_url":"https://github.com/perpetualjourney/connectbot","homepage":"https://connectbot.org/","size":6180,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"connectbot:master","ref":"master","sha":"25351427af999f65d843801a08007172e7baa010","user":{"login":"connectbot","id":5605419,"avatar_url":"https://avatars.githubusercontent.com/u/5605419?v=3","gravatar_id":"","url":"https://api.github.com/users/connectbot","html_url":"https://github.com/connectbot","followers_url":"https://api.github.com/users/connectbot/followers","following_url":"https://api.github.com/users/connectbot/following{/other_user}","gists_url":"https://api.github.com/users/connectbot/gists{/gist_id}","starred_url":"https://api.github.com/users/connectbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/connectbot/subscriptions","organizations_url":"https://api.github.com/users/connectbot/orgs","repos_url":"https://api.github.com/users/connectbot/repos","events_url":"https://api.github.com/users/connectbot/events{/privacy}","received_events_url":"https://api.github.com/users/connectbot/received_events","type":"Organization","site_admin":false},"repo":{"id":123235,"name":"connectbot","full_name":"connectbot/connectbot","owner":{"login":"connectbot","id":5605419,"avatar_url":"https://avatars.githubusercontent.com/u/5605419?v=3","gravatar_id":"","url":"https://api.github.com/users/connectbot","html_url":"https://github.com/connectbot","followers_url":"https://api.github.com/users/connectbot/followers","following_url":"https://api.github.com/users/connectbot/following{/other_user}","gists_url":"https://api.github.com/users/connectbot/gists{/gist_id}","starred_url":"https://api.github.com/users/connectbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/connectbot/subscriptions","organizations_url":"https://api.github.com/users/connectbot/orgs","repos_url":"https://api.github.com/users/connectbot/repos","events_url":"https://api.github.com/users/connectbot/events{/privacy}","received_events_url":"https://api.github.com/users/connectbot/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/connectbot/connectbot","description":"ConnectBot is the first SSH client for Android.","fork":false,"url":"https://api.github.com/repos/connectbot/connectbot","forks_url":"https://api.github.com/repos/connectbot/connectbot/forks","keys_url":"https://api.github.com/repos/connectbot/connectbot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/connectbot/connectbot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/connectbot/connectbot/teams","hooks_url":"https://api.github.com/repos/connectbot/connectbot/hooks","issue_events_url":"https://api.github.com/repos/connectbot/connectbot/issues/events{/number}","events_url":"https://api.github.com/repos/connectbot/connectbot/events","assignees_url":"https://api.github.com/repos/connectbot/connectbot/assignees{/user}","branches_url":"https://api.github.com/repos/connectbot/connectbot/branches{/branch}","tags_url":"https://api.github.com/repos/connectbot/connectbot/tags","blobs_url":"https://api.github.com/repos/connectbot/connectbot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/connectbot/connectbot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/connectbot/connectbot/git/refs{/sha}","trees_url":"https://api.github.com/repos/connectbot/connectbot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/connectbot/connectbot/statuses/{sha}","languages_url":"https://api.github.com/repos/connectbot/connectbot/languages","stargazers_url":"https://api.github.com/repos/connectbot/connectbot/stargazers","contributors_url":"https://api.github.com/repos/connectbot/connectbot/contributors","subscribers_url":"https://api.github.com/repos/connectbot/connectbot/subscribers","subscription_url":"https://api.github.com/repos/connectbot/connectbot/subscription","commits_url":"https://api.github.com/repos/connectbot/connectbot/commits{/sha}","git_commits_url":"https://api.github.com/repos/connectbot/connectbot/git/commits{/sha}","comments_url":"https://api.github.com/repos/connectbot/connectbot/comments{/number}","issue_comment_url":"https://api.github.com/repos/connectbot/connectbot/issues/comments{/number}","contents_url":"https://api.github.com/repos/connectbot/connectbot/contents/{+path}","compare_url":"https://api.github.com/repos/connectbot/connectbot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/connectbot/connectbot/merges","archive_url":"https://api.github.com/repos/connectbot/connectbot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/connectbot/connectbot/downloads","issues_url":"https://api.github.com/repos/connectbot/connectbot/issues{/number}","pulls_url":"https://api.github.com/repos/connectbot/connectbot/pulls{/number}","milestones_url":"https://api.github.com/repos/connectbot/connectbot/milestones{/number}","notifications_url":"https://api.github.com/repos/connectbot/connectbot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/connectbot/connectbot/labels{/name}","releases_url":"https://api.github.com/repos/connectbot/connectbot/releases{/id}","deployments_url":"https://api.github.com/repos/connectbot/connectbot/deployments","created_at":"2009-02-06T17:52:35Z","updated_at":"2016-11-18T00:26:50Z","pushed_at":"2016-11-19T05:52:42Z","git_url":"git://github.com/connectbot/connectbot.git","ssh_url":"git@github.com:connectbot/connectbot.git","clone_url":"https://github.com/connectbot/connectbot.git","svn_url":"https://github.com/connectbot/connectbot","homepage":"https://connectbot.org/","size":9555,"stargazers_count":708,"watchers_count":708,"language":"Java","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":324,"mirror_url":null,"open_issues_count":108,"forks":324,"open_issues":108,"watchers":708,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/connectbot/connectbot/pulls/448"},"html":{"href":"https://github.com/connectbot/connectbot/pull/448"},"issue":{"href":"https://api.github.com/repos/connectbot/connectbot/issues/448"},"comments":{"href":"https://api.github.com/repos/connectbot/connectbot/issues/448/comments"},"review_comments":{"href":"https://api.github.com/repos/connectbot/connectbot/pulls/448/comments"},"review_comment":{"href":"https://api.github.com/repos/connectbot/connectbot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/connectbot/connectbot/pulls/448/commits"},"statuses":{"href":"https://api.github.com/repos/connectbot/connectbot/statuses/4ce1ed42ebd79224828d6bb1992c5d4beaf24999"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"kruton","id":50407,"avatar_url":"https://avatars.githubusercontent.com/u/50407?v=3","gravatar_id":"","url":"https://api.github.com/users/kruton","html_url":"https://github.com/kruton","followers_url":"https://api.github.com/users/kruton/followers","following_url":"https://api.github.com/users/kruton/following{/other_user}","gists_url":"https://api.github.com/users/kruton/gists{/gist_id}","starred_url":"https://api.github.com/users/kruton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kruton/subscriptions","organizations_url":"https://api.github.com/users/kruton/orgs","repos_url":"https://api.github.com/users/kruton/repos","events_url":"https://api.github.com/users/kruton/events{/privacy}","received_events_url":"https://api.github.com/users/kruton/received_events","type":"User","site_admin":false},"comments":3,"review_comments":2,"commits":2,"additions":16,"deletions":13,"changed_files":1}}
{"actor":{"display_login":"kruton"}}