{"action":"created","comment":{"url":"https://api.github.com/repos/sm00th/bitlbee-discord/pulls/comments/211520956","pull_request_review_id":147954068,"id":211520956,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMTUyMDk1Ng==","diff_hunk":"@@ -190,11 +190,21 @@ static void discord_handle_relationship(struct im_connection *ic, json_value *ri\n {\n   discord_data *dd = ic->proto_data;\n   relationship_type rtype = 0;\n-  json_value *uinfo = json_o_get(rinfo, \"user\");\n+  char *name = NULL;\n+  json_value *uinfo = NULL;\n+  bee_user_t *bu = NULL;\n+\n+  if(action == ACTION_DELETE) {","path":"src/discord-handlers.c","position":9,"original_position":9,"commit_id":"c9c4da06cc89debcb8adafecdb5060b53408eead","original_commit_id":"c9c4da06cc89debcb8adafecdb5060b53408eead","user":{"login":"sm00th","id":194702,"node_id":"MDQ6VXNlcjE5NDcwMg==","avatar_url":"https://avatars2.githubusercontent.com/u/194702?v=4","gravatar_id":"","url":"https://api.github.com/users/sm00th","html_url":"https://github.com/sm00th","followers_url":"https://api.github.com/users/sm00th/followers","following_url":"https://api.github.com/users/sm00th/following{/other_user}","gists_url":"https://api.github.com/users/sm00th/gists{/gist_id}","starred_url":"https://api.github.com/users/sm00th/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sm00th/subscriptions","organizations_url":"https://api.github.com/users/sm00th/orgs","repos_url":"https://api.github.com/users/sm00th/repos","events_url":"https://api.github.com/users/sm00th/events{/privacy}","received_events_url":"https://api.github.com/users/sm00th/received_events","type":"User","site_admin":false},"body":"There is already an `if (action ...` statement in this function, I think we should use it instead of adding a new one.","created_at":"2018-08-21T08:33:38Z","updated_at":"2018-08-21T08:36:23Z","html_url":"https://github.com/sm00th/bitlbee-discord/pull/171#discussion_r211520956","pull_request_url":"https://api.github.com/repos/sm00th/bitlbee-discord/pulls/171","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/sm00th/bitlbee-discord/pulls/comments/211520956"},"html":{"href":"https://github.com/sm00th/bitlbee-discord/pull/171#discussion_r211520956"},"pull_request":{"href":"https://api.github.com/repos/sm00th/bitlbee-discord/pulls/171"}}},"pull_request":{"url":"https://api.github.com/repos/sm00th/bitlbee-discord/pulls/171","id":209655464,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA5NjU1NDY0","html_url":"https://github.com/sm00th/bitlbee-discord/pull/171","diff_url":"https://github.com/sm00th/bitlbee-discord/pull/171.diff","patch_url":"https://github.com/sm00th/bitlbee-discord/pull/171.patch","issue_url":"https://api.github.com/repos/sm00th/bitlbee-discord/issues/171","number":171,"state":"open","locked":false,"title":"Added fixes for crashing upon somebody removing you from their friends.","user":{"login":"katslime","id":30964244,"node_id":"MDQ6VXNlcjMwOTY0MjQ0","avatar_url":"https://avatars1.githubusercontent.com/u/30964244?v=4","gravatar_id":"","url":"https://api.github.com/users/katslime","html_url":"https://github.com/katslime","followers_url":"https://api.github.com/users/katslime/followers","following_url":"https://api.github.com/users/katslime/following{/other_user}","gists_url":"https://api.github.com/users/katslime/gists{/gist_id}","starred_url":"https://api.github.com/users/katslime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/katslime/subscriptions","organizations_url":"https://api.github.com/users/katslime/orgs","repos_url":"https://api.github.com/users/katslime/repos","events_url":"https://api.github.com/users/katslime/events{/privacy}","received_events_url":"https://api.github.com/users/katslime/received_events","type":"User","site_admin":false},"body":"Before these fixes, RELATIONSHIP_REMOVE would cause a segfault. My understanding of this, is that RELATIONSHIP_REMOVE's json looks like: `{\"t\":\"RELATIONSHIP_REMOVE\",\"s\":97,\"op\":0,\"d\":{\"type\":1,\"id\":\"<removed>\"}}` and this is the primary cause of this problem.\r\n\r\nIn the original code, `json_value *uinfo = json_o_get(rinfo, \"user\");` would lead to a null pointer being fed into discord_canonize_name as `char *name = discord_canonize_name(json_o_str(uinfo, \"username\"));` has no handling for being fed a null pointer. This then causes a segmentation fault, as follows:\r\n\r\n```\r\nProgram received signal SIGSEGV, Segmentation fault.\r\n0x000055555558cd4b in str_reject_chars (string=0x0, reject=0x7ffff7fc90c6 \"@+ \", replacement=95 '_') at misc.c:741\r\n741\t\twhile (*c) {\r\n#0  0x000055555558cd4b in str_reject_chars (string=0x0, reject=0x7ffff7fc90c6 \"@+ \", replacement=95 '_') at misc.c:741\r\n#1  0x00007ffff7fc1bea in ?? () from /usr/local/lib/bitlbee/discord.so\r\n#2  0x00007ffff7fc41b3 in discord_parse_message () from /usr/local/lib/bitlbee/discord.so\r\n#3  0x00007ffff7fc6826 in ?? () from /usr/local/lib/bitlbee/discord.so\r\n#4  0x00005555555862e7 in gaim_io_invoke (source=0x555555657a70, condition=G_IO_IN, data=0x55555566a0e0) at events_glib.c:86\r\n#5  0x00007ffff793e1d6 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0\r\n#6  0x00007ffff793e5b1 in ?? () from /usr/lib/libglib-2.0.so.0\r\n#7  0x00007ffff793e8e2 in g_main_loop_run () from /usr/lib/libglib-2.0.so.0\r\n#8  0x0000555555586257 in b_main_run () at events_glib.c:59\r\n#9  0x0000555555583100 in main (argc=4, argv=0x7fffffffe588) at unix.c:196\r\n(gdb)\r\n```\r\n\r\nInstead of adding in specific null pointer handling, I reworked it to get the ID from the request and to use get_user to get the user from that, instead. This is probably a messy fix and a better fix would be to break up discord_handle_relationship into more than one function and handle each seperately.","created_at":"2018-08-20T21:59:02Z","updated_at":"2018-08-21T08:36:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2dd7fc37d73a6e7ece4ce5c2e53fde55d326cca0","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/sm00th/bitlbee-discord/pulls/171/commits","review_comments_url":"https://api.github.com/repos/sm00th/bitlbee-discord/pulls/171/comments","review_comment_url":"https://api.github.com/repos/sm00th/bitlbee-discord/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sm00th/bitlbee-discord/issues/171/comments","statuses_url":"https://api.github.com/repos/sm00th/bitlbee-discord/statuses/c9c4da06cc89debcb8adafecdb5060b53408eead","head":{"label":"katslime:master","ref":"master","sha":"c9c4da06cc89debcb8adafecdb5060b53408eead","user":{"login":"katslime","id":30964244,"node_id":"MDQ6VXNlcjMwOTY0MjQ0","avatar_url":"https://avatars1.githubusercontent.com/u/30964244?v=4","gravatar_id":"","url":"https://api.github.com/users/katslime","html_url":"https://github.com/katslime","followers_url":"https://api.github.com/users/katslime/followers","following_url":"https://api.github.com/users/katslime/following{/other_user}","gists_url":"https://api.github.com/users/katslime/gists{/gist_id}","starred_url":"https://api.github.com/users/katslime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/katslime/subscriptions","organizations_url":"https://api.github.com/users/katslime/orgs","repos_url":"https://api.github.com/users/katslime/repos","events_url":"https://api.github.com/users/katslime/events{/privacy}","received_events_url":"https://api.github.com/users/katslime/received_events","type":"User","site_admin":false},"repo":{"id":145473837,"node_id":"MDEwOlJlcG9zaXRvcnkxNDU0NzM4Mzc=","name":"bitlbee-discord","full_name":"katslime/bitlbee-discord","owner":{"login":"katslime","id":30964244,"node_id":"MDQ6VXNlcjMwOTY0MjQ0","avatar_url":"https://avatars1.githubusercontent.com/u/30964244?v=4","gravatar_id":"","url":"https://api.github.com/users/katslime","html_url":"https://github.com/katslime","followers_url":"https://api.github.com/users/katslime/followers","following_url":"https://api.github.com/users/katslime/following{/other_user}","gists_url":"https://api.github.com/users/katslime/gists{/gist_id}","starred_url":"https://api.github.com/users/katslime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/katslime/subscriptions","organizations_url":"https://api.github.com/users/katslime/orgs","repos_url":"https://api.github.com/users/katslime/repos","events_url":"https://api.github.com/users/katslime/events{/privacy}","received_events_url":"https://api.github.com/users/katslime/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/katslime/bitlbee-discord","description":"Bitlbee plugin for Discord (http://discordapp.com)","fork":true,"url":"https://api.github.com/repos/katslime/bitlbee-discord","forks_url":"https://api.github.com/repos/katslime/bitlbee-discord/forks","keys_url":"https://api.github.com/repos/katslime/bitlbee-discord/keys{/key_id}","collaborators_url":"https://api.github.com/repos/katslime/bitlbee-discord/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/katslime/bitlbee-discord/teams","hooks_url":"https://api.github.com/repos/katslime/bitlbee-discord/hooks","issue_events_url":"https://api.github.com/repos/katslime/bitlbee-discord/issues/events{/number}","events_url":"https://api.github.com/repos/katslime/bitlbee-discord/events","assignees_url":"https://api.github.com/repos/katslime/bitlbee-discord/assignees{/user}","branches_url":"https://api.github.com/repos/katslime/bitlbee-discord/branches{/branch}","tags_url":"https://api.github.com/repos/katslime/bitlbee-discord/tags","blobs_url":"https://api.github.com/repos/katslime/bitlbee-discord/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/katslime/bitlbee-discord/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/katslime/bitlbee-discord/git/refs{/sha}","trees_url":"https://api.github.com/repos/katslime/bitlbee-discord/git/trees{/sha}","statuses_url":"https://api.github.com/repos/katslime/bitlbee-discord/statuses/{sha}","languages_url":"https://api.github.com/repos/katslime/bitlbee-discord/languages","stargazers_url":"https://api.github.com/repos/katslime/bitlbee-discord/stargazers","contributors_url":"https://api.github.com/repos/katslime/bitlbee-discord/contributors","subscribers_url":"https://api.github.com/repos/katslime/bitlbee-discord/subscribers","subscription_url":"https://api.github.com/repos/katslime/bitlbee-discord/subscription","commits_url":"https://api.github.com/repos/katslime/bitlbee-discord/commits{/sha}","git_commits_url":"https://api.github.com/repos/katslime/bitlbee-discord/git/commits{/sha}","comments_url":"https://api.github.com/repos/katslime/bitlbee-discord/comments{/number}","issue_comment_url":"https://api.github.com/repos/katslime/bitlbee-discord/issues/comments{/number}","contents_url":"https://api.github.com/repos/katslime/bitlbee-discord/contents/{+path}","compare_url":"https://api.github.com/repos/katslime/bitlbee-discord/compare/{base}...{head}","merges_url":"https://api.github.com/repos/katslime/bitlbee-discord/merges","archive_url":"https://api.github.com/repos/katslime/bitlbee-discord/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/katslime/bitlbee-discord/downloads","issues_url":"https://api.github.com/repos/katslime/bitlbee-discord/issues{/number}","pulls_url":"https://api.github.com/repos/katslime/bitlbee-discord/pulls{/number}","milestones_url":"https://api.github.com/repos/katslime/bitlbee-discord/milestones{/number}","notifications_url":"https://api.github.com/repos/katslime/bitlbee-discord/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/katslime/bitlbee-discord/labels{/name}","releases_url":"https://api.github.com/repos/katslime/bitlbee-discord/releases{/id}","deployments_url":"https://api.github.com/repos/katslime/bitlbee-discord/deployments","created_at":"2018-08-20T21:48:01Z","updated_at":"2018-08-20T22:23:17Z","pushed_at":"2018-08-20T22:23:15Z","git_url":"git://github.com/katslime/bitlbee-discord.git","ssh_url":"git@github.com:katslime/bitlbee-discord.git","clone_url":"https://github.com/katslime/bitlbee-discord.git","svn_url":"https://github.com/katslime/bitlbee-discord","homepage":null,"size":286,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0","node_id":"MDc6TGljZW5zZTg="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"sm00th:master","ref":"master","sha":"fd8213fbd9e993a0328aebe34e4aa2c6aea57a1c","user":{"login":"sm00th","id":194702,"node_id":"MDQ6VXNlcjE5NDcwMg==","avatar_url":"https://avatars2.githubusercontent.com/u/194702?v=4","gravatar_id":"","url":"https://api.github.com/users/sm00th","html_url":"https://github.com/sm00th","followers_url":"https://api.github.com/users/sm00th/followers","following_url":"https://api.github.com/users/sm00th/following{/other_user}","gists_url":"https://api.github.com/users/sm00th/gists{/gist_id}","starred_url":"https://api.github.com/users/sm00th/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sm00th/subscriptions","organizations_url":"https://api.github.com/users/sm00th/orgs","repos_url":"https://api.github.com/users/sm00th/repos","events_url":"https://api.github.com/users/sm00th/events{/privacy}","received_events_url":"https://api.github.com/users/sm00th/received_events","type":"User","site_admin":false},"repo":{"id":43824857,"node_id":"MDEwOlJlcG9zaXRvcnk0MzgyNDg1Nw==","name":"bitlbee-discord","full_name":"sm00th/bitlbee-discord","owner":{"login":"sm00th","id":194702,"node_id":"MDQ6VXNlcjE5NDcwMg==","avatar_url":"https://avatars2.githubusercontent.com/u/194702?v=4","gravatar_id":"","url":"https://api.github.com/users/sm00th","html_url":"https://github.com/sm00th","followers_url":"https://api.github.com/users/sm00th/followers","following_url":"https://api.github.com/users/sm00th/following{/other_user}","gists_url":"https://api.github.com/users/sm00th/gists{/gist_id}","starred_url":"https://api.github.com/users/sm00th/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sm00th/subscriptions","organizations_url":"https://api.github.com/users/sm00th/orgs","repos_url":"https://api.github.com/users/sm00th/repos","events_url":"https://api.github.com/users/sm00th/events{/privacy}","received_events_url":"https://api.github.com/users/sm00th/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sm00th/bitlbee-discord","description":"Bitlbee plugin for Discord (http://discordapp.com)","fork":false,"url":"https://api.github.com/repos/sm00th/bitlbee-discord","forks_url":"https://api.github.com/repos/sm00th/bitlbee-discord/forks","keys_url":"https://api.github.com/repos/sm00th/bitlbee-discord/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sm00th/bitlbee-discord/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sm00th/bitlbee-discord/teams","hooks_url":"https://api.github.com/repos/sm00th/bitlbee-discord/hooks","issue_events_url":"https://api.github.com/repos/sm00th/bitlbee-discord/issues/events{/number}","events_url":"https://api.github.com/repos/sm00th/bitlbee-discord/events","assignees_url":"https://api.github.com/repos/sm00th/bitlbee-discord/assignees{/user}","branches_url":"https://api.github.com/repos/sm00th/bitlbee-discord/branches{/branch}","tags_url":"https://api.github.com/repos/sm00th/bitlbee-discord/tags","blobs_url":"https://api.github.com/repos/sm00th/bitlbee-discord/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sm00th/bitlbee-discord/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sm00th/bitlbee-discord/git/refs{/sha}","trees_url":"https://api.github.com/repos/sm00th/bitlbee-discord/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sm00th/bitlbee-discord/statuses/{sha}","languages_url":"https://api.github.com/repos/sm00th/bitlbee-discord/languages","stargazers_url":"https://api.github.com/repos/sm00th/bitlbee-discord/stargazers","contributors_url":"https://api.github.com/repos/sm00th/bitlbee-discord/contributors","subscribers_url":"https://api.github.com/repos/sm00th/bitlbee-discord/subscribers","subscription_url":"https://api.github.com/repos/sm00th/bitlbee-discord/subscription","commits_url":"https://api.github.com/repos/sm00th/bitlbee-discord/commits{/sha}","git_commits_url":"https://api.github.com/repos/sm00th/bitlbee-discord/git/commits{/sha}","comments_url":"https://api.github.com/repos/sm00th/bitlbee-discord/comments{/number}","issue_comment_url":"https://api.github.com/repos/sm00th/bitlbee-discord/issues/comments{/number}","contents_url":"https://api.github.com/repos/sm00th/bitlbee-discord/contents/{+path}","compare_url":"https://api.github.com/repos/sm00th/bitlbee-discord/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sm00th/bitlbee-discord/merges","archive_url":"https://api.github.com/repos/sm00th/bitlbee-discord/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sm00th/bitlbee-discord/downloads","issues_url":"https://api.github.com/repos/sm00th/bitlbee-discord/issues{/number}","pulls_url":"https://api.github.com/repos/sm00th/bitlbee-discord/pulls{/number}","milestones_url":"https://api.github.com/repos/sm00th/bitlbee-discord/milestones{/number}","notifications_url":"https://api.github.com/repos/sm00th/bitlbee-discord/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sm00th/bitlbee-discord/labels{/name}","releases_url":"https://api.github.com/repos/sm00th/bitlbee-discord/releases{/id}","deployments_url":"https://api.github.com/repos/sm00th/bitlbee-discord/deployments","created_at":"2015-10-07T15:18:54Z","updated_at":"2018-08-20T08:48:16Z","pushed_at":"2018-08-20T22:23:17Z","git_url":"git://github.com/sm00th/bitlbee-discord.git","ssh_url":"git@github.com:sm00th/bitlbee-discord.git","clone_url":"https://github.com/sm00th/bitlbee-discord.git","svn_url":"https://github.com/sm00th/bitlbee-discord","homepage":null,"size":279,"stargazers_count":114,"watchers_count":114,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":20,"mirror_url":null,"archived":false,"open_issues_count":42,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0","node_id":"MDc6TGljZW5zZTg="},"forks":20,"open_issues":42,"watchers":114,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sm00th/bitlbee-discord/pulls/171"},"html":{"href":"https://github.com/sm00th/bitlbee-discord/pull/171"},"issue":{"href":"https://api.github.com/repos/sm00th/bitlbee-discord/issues/171"},"comments":{"href":"https://api.github.com/repos/sm00th/bitlbee-discord/issues/171/comments"},"review_comments":{"href":"https://api.github.com/repos/sm00th/bitlbee-discord/pulls/171/comments"},"review_comment":{"href":"https://api.github.com/repos/sm00th/bitlbee-discord/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sm00th/bitlbee-discord/pulls/171/commits"},"statuses":{"href":"https://api.github.com/repos/sm00th/bitlbee-discord/statuses/c9c4da06cc89debcb8adafecdb5060b53408eead"}},"author_association":"NONE"}}
{"actor":{"display_login":"sm00th"}}