{"action":"created","comment":{"url":"https://api.github.com/repos/radare/radare2/pulls/comments/217928815","pull_request_review_id":155759087,"id":217928815,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNzkyODgxNQ==","diff_hunk":"@@ -702,7 +702,7 @@ R_API void extract_rarg(RAnal *anal, RAnalOp *op, RAnalFunction *fcn, int *reg_s\n \t\t\t\t!strcmp (opdreg, regname);\n \t\t\tif ((op->src[0] && opsreg && !strcmp (opsreg, regname)) || cond) {\n \t\t\t\tconst char *vname = NULL;\n-\t\t\t\tconst char *type = \"int\";\n+\t\t\t\tconst char *type = NULL;","path":"libr/anal/var.c","position":5,"original_position":5,"commit_id":"55427f31bf832beaa4af15c8973a3fc5e36ffc0f","original_commit_id":"55427f31bf832beaa4af15c8973a3fc5e36ffc0f","user":{"login":"ret2libc","id":562321,"node_id":"MDQ6VXNlcjU2MjMyMQ==","avatar_url":"https://avatars2.githubusercontent.com/u/562321?v=4","gravatar_id":"","url":"https://api.github.com/users/ret2libc","html_url":"https://github.com/ret2libc","followers_url":"https://api.github.com/users/ret2libc/followers","following_url":"https://api.github.com/users/ret2libc/following{/other_user}","gists_url":"https://api.github.com/users/ret2libc/gists{/gist_id}","starred_url":"https://api.github.com/users/ret2libc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ret2libc/subscriptions","organizations_url":"https://api.github.com/users/ret2libc/orgs","repos_url":"https://api.github.com/users/ret2libc/repos","events_url":"https://api.github.com/users/ret2libc/events{/privacy}","received_events_url":"https://api.github.com/users/ret2libc/received_events","type":"User","site_admin":false},"body":"As said by @radare in another commit, use `type ? type : \"int\"` in the line when `type` is used. This, however, should be `char *` AFAIK, given it's used as argument to free later.","created_at":"2018-09-16T21:46:06Z","updated_at":"2018-09-16T21:46:06Z","html_url":"https://github.com/radare/radare2/pull/11543#discussion_r217928815","pull_request_url":"https://api.github.com/repos/radare/radare2/pulls/11543","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/radare/radare2/pulls/comments/217928815"},"html":{"href":"https://github.com/radare/radare2/pull/11543#discussion_r217928815"},"pull_request":{"href":"https://api.github.com/repos/radare/radare2/pulls/11543"}},"in_reply_to_id":217927786},"pull_request":{"url":"https://api.github.com/repos/radare/radare2/pulls/11543","id":215841239,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE1ODQxMjM5","html_url":"https://github.com/radare/radare2/pull/11543","diff_url":"https://github.com/radare/radare2/pull/11543.diff","patch_url":"https://github.com/radare/radare2/pull/11543.patch","issue_url":"https://api.github.com/repos/radare/radare2/issues/11543","number":11543,"state":"open","locked":false,"title":"Fix a small memory leak in extract_rarg()","user":{"login":"pageflt","id":706520,"node_id":"MDQ6VXNlcjcwNjUyMA==","avatar_url":"https://avatars1.githubusercontent.com/u/706520?v=4","gravatar_id":"","url":"https://api.github.com/users/pageflt","html_url":"https://github.com/pageflt","followers_url":"https://api.github.com/users/pageflt/followers","following_url":"https://api.github.com/users/pageflt/following{/other_user}","gists_url":"https://api.github.com/users/pageflt/gists{/gist_id}","starred_url":"https://api.github.com/users/pageflt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pageflt/subscriptions","organizations_url":"https://api.github.com/users/pageflt/orgs","repos_url":"https://api.github.com/users/pageflt/repos","events_url":"https://api.github.com/users/pageflt/events{/privacy}","received_events_url":"https://api.github.com/users/pageflt/received_events","type":"User","site_admin":false},"body":"This PR addresses the following issue:\r\n\r\n- **Fix a small memory leak in extract_rarg()**\r\n\r\nASAN reports a memory leak within extract_rarg() because `type` is not\r\nproperly freed upon being allocated within `r_type_func_args_type()`.\r\nIt's safe to set `type` to NULL: it's only passed to r_anal_var_add(),\r\nwhich already initializes it to its default value (\"int\").\r\n\r\nReproduction:\r\n\r\nASAN build (`ASAN=\"address leak\"`) on `Ubuntu 18.04.1 LTS`, running\r\n`radare2 3.0.0-git 19469 @ linux-x86-64 git.2.9.0-109-g4014e938d`:\r\n\r\n```\r\n$ r2 -A /bin/ls\r\n[x] Analyze all flags starting with sym. and entry0 (aa)\r\n[x] Analyze function calls (aac)\r\n[x] Analyze len bytes of instructions for references (aar)\r\n[x] Constructing a function name for fcn.* and sym.func.* functions (aan)\r\n[x] Type matching analysis for all functions (afta)\r\n[x] Use -AA or aaaa to perform additional experimental analysis.\r\n -- I did it for the pwnz.\r\n[0x00005850]> q\r\n\r\n=================================================================\r\n==6647==ERROR: LeakSanitizer: detected memory leaks\r\n\r\nDirect leak of 35 byte(s) in 3 object(s) allocated from:\r\n    #0 0x7fcd8a7b4538 in strdup (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x77538)\r\n    #1 0x7fcd84a73c9b in sdb_get_len /home/pageflt/gitroot/pageflt/radare2/shlr/sdb/src/sdb.c:276\r\n    #2 0x7fcd84a73cd4 in sdb_get /home/pageflt/gitroot/pageflt/radare2/shlr/sdb/src/sdb.c:280\r\n    #3 0x7fcd84a1d620 in r_type_func_args_type /home/pageflt/gitroot/pageflt/radare2/libr/util/ctype.c:461\r\n    #4 0x7fcd8802e545 in extract_rarg /home/pageflt/gitroot/pageflt/radare2/libr/anal/var.c:713\r\n    #5 0x7fcd8a29b2d4 in r_core_recover_vars /home/pageflt/gitroot/pageflt/radare2/libr/core/canal.c:2659\r\n    #6 0x7fcd8a29f68d in r_core_anal_all /home/pageflt/gitroot/pageflt/radare2/libr/core/canal.c:3253\r\n    #7 0x7fcd8a14c235 in cmd_anal_all /home/pageflt/gitroot/pageflt/radare2/libr/core/cmd_anal.c:7024\r\n    #8 0x7fcd8a14eaaf in cmd_anal /home/pageflt/gitroot/pageflt/radare2/libr/core/cmd_anal.c:7442\r\n    #9 0x7fcd8a2804c2 in r_cmd_call /home/pageflt/gitroot/pageflt/radare2/libr/core/cmd_api.c:239\r\n    #10 0x7fcd8a1db85e in r_core_cmd_subst_i /home/pageflt/gitroot/pageflt/radare2/libr/core/cmd.c:2949\r\n    #11 0x7fcd8a1d445f in r_core_cmd_subst /home/pageflt/gitroot/pageflt/radare2/libr/core/cmd.c:1955\r\n    #12 0x7fcd8a1e0cd8 in r_core_cmd /home/pageflt/gitroot/pageflt/radare2/libr/core/cmd.c:3668\r\n    #13 0x7fcd8a1e19f5 in r_core_cmd0 /home/pageflt/gitroot/pageflt/radare2/libr/core/cmd.c:3834\r\n    #14 0x55d152a67103 in main /home/pageflt/gitroot/pageflt/radare2/binr/radare2/radare2.c:1352\r\n    #15 0x7fcd84304b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)\r\n\r\nSUMMARY: AddressSanitizer: 35 byte(s) leaked in 3 allocation(s).\r\n```\r\n","created_at":"2018-09-16T19:39:39Z","updated_at":"2018-09-16T21:46:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2fc3a8b693f45809e29ba202930075b98b7788a3","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/radare/radare2/pulls/11543/commits","review_comments_url":"https://api.github.com/repos/radare/radare2/pulls/11543/comments","review_comment_url":"https://api.github.com/repos/radare/radare2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/radare/radare2/issues/11543/comments","statuses_url":"https://api.github.com/repos/radare/radare2/statuses/55427f31bf832beaa4af15c8973a3fc5e36ffc0f","head":{"label":"pageflt:extract_rarg_memleak","ref":"extract_rarg_memleak","sha":"55427f31bf832beaa4af15c8973a3fc5e36ffc0f","user":{"login":"pageflt","id":706520,"node_id":"MDQ6VXNlcjcwNjUyMA==","avatar_url":"https://avatars1.githubusercontent.com/u/706520?v=4","gravatar_id":"","url":"https://api.github.com/users/pageflt","html_url":"https://github.com/pageflt","followers_url":"https://api.github.com/users/pageflt/followers","following_url":"https://api.github.com/users/pageflt/following{/other_user}","gists_url":"https://api.github.com/users/pageflt/gists{/gist_id}","starred_url":"https://api.github.com/users/pageflt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pageflt/subscriptions","organizations_url":"https://api.github.com/users/pageflt/orgs","repos_url":"https://api.github.com/users/pageflt/repos","events_url":"https://api.github.com/users/pageflt/events{/privacy}","received_events_url":"https://api.github.com/users/pageflt/received_events","type":"User","site_admin":false},"repo":{"id":148635931,"node_id":"MDEwOlJlcG9zaXRvcnkxNDg2MzU5MzE=","name":"radare2","full_name":"pageflt/radare2","private":false,"owner":{"login":"pageflt","id":706520,"node_id":"MDQ6VXNlcjcwNjUyMA==","avatar_url":"https://avatars1.githubusercontent.com/u/706520?v=4","gravatar_id":"","url":"https://api.github.com/users/pageflt","html_url":"https://github.com/pageflt","followers_url":"https://api.github.com/users/pageflt/followers","following_url":"https://api.github.com/users/pageflt/following{/other_user}","gists_url":"https://api.github.com/users/pageflt/gists{/gist_id}","starred_url":"https://api.github.com/users/pageflt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pageflt/subscriptions","organizations_url":"https://api.github.com/users/pageflt/orgs","repos_url":"https://api.github.com/users/pageflt/repos","events_url":"https://api.github.com/users/pageflt/events{/privacy}","received_events_url":"https://api.github.com/users/pageflt/received_events","type":"User","site_admin":false},"html_url":"https://github.com/pageflt/radare2","description":"unix-like reverse engineering framework and commandline tools security","fork":true,"url":"https://api.github.com/repos/pageflt/radare2","forks_url":"https://api.github.com/repos/pageflt/radare2/forks","keys_url":"https://api.github.com/repos/pageflt/radare2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pageflt/radare2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pageflt/radare2/teams","hooks_url":"https://api.github.com/repos/pageflt/radare2/hooks","issue_events_url":"https://api.github.com/repos/pageflt/radare2/issues/events{/number}","events_url":"https://api.github.com/repos/pageflt/radare2/events","assignees_url":"https://api.github.com/repos/pageflt/radare2/assignees{/user}","branches_url":"https://api.github.com/repos/pageflt/radare2/branches{/branch}","tags_url":"https://api.github.com/repos/pageflt/radare2/tags","blobs_url":"https://api.github.com/repos/pageflt/radare2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pageflt/radare2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pageflt/radare2/git/refs{/sha}","trees_url":"https://api.github.com/repos/pageflt/radare2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pageflt/radare2/statuses/{sha}","languages_url":"https://api.github.com/repos/pageflt/radare2/languages","stargazers_url":"https://api.github.com/repos/pageflt/radare2/stargazers","contributors_url":"https://api.github.com/repos/pageflt/radare2/contributors","subscribers_url":"https://api.github.com/repos/pageflt/radare2/subscribers","subscription_url":"https://api.github.com/repos/pageflt/radare2/subscription","commits_url":"https://api.github.com/repos/pageflt/radare2/commits{/sha}","git_commits_url":"https://api.github.com/repos/pageflt/radare2/git/commits{/sha}","comments_url":"https://api.github.com/repos/pageflt/radare2/comments{/number}","issue_comment_url":"https://api.github.com/repos/pageflt/radare2/issues/comments{/number}","contents_url":"https://api.github.com/repos/pageflt/radare2/contents/{+path}","compare_url":"https://api.github.com/repos/pageflt/radare2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pageflt/radare2/merges","archive_url":"https://api.github.com/repos/pageflt/radare2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pageflt/radare2/downloads","issues_url":"https://api.github.com/repos/pageflt/radare2/issues{/number}","pulls_url":"https://api.github.com/repos/pageflt/radare2/pulls{/number}","milestones_url":"https://api.github.com/repos/pageflt/radare2/milestones{/number}","notifications_url":"https://api.github.com/repos/pageflt/radare2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pageflt/radare2/labels{/name}","releases_url":"https://api.github.com/repos/pageflt/radare2/releases{/id}","deployments_url":"https://api.github.com/repos/pageflt/radare2/deployments","created_at":"2018-09-13T12:42:08Z","updated_at":"2018-09-16T18:52:38Z","pushed_at":"2018-09-16T19:37:18Z","git_url":"git://github.com/pageflt/radare2.git","ssh_url":"git@github.com:pageflt/radare2.git","clone_url":"https://github.com/pageflt/radare2.git","svn_url":"https://github.com/pageflt/radare2","homepage":"http://www.radare.org/","size":90277,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0","node_id":"MDc6TGljZW5zZTEy"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"radare:master","ref":"master","sha":"405cddffcab39725ab67840d4cec9f48156f1a7c","user":{"login":"radare","id":917142,"node_id":"MDQ6VXNlcjkxNzE0Mg==","avatar_url":"https://avatars1.githubusercontent.com/u/917142?v=4","gravatar_id":"","url":"https://api.github.com/users/radare","html_url":"https://github.com/radare","followers_url":"https://api.github.com/users/radare/followers","following_url":"https://api.github.com/users/radare/following{/other_user}","gists_url":"https://api.github.com/users/radare/gists{/gist_id}","starred_url":"https://api.github.com/users/radare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radare/subscriptions","organizations_url":"https://api.github.com/users/radare/orgs","repos_url":"https://api.github.com/users/radare/repos","events_url":"https://api.github.com/users/radare/events{/privacy}","received_events_url":"https://api.github.com/users/radare/received_events","type":"User","site_admin":false},"repo":{"id":4869294,"node_id":"MDEwOlJlcG9zaXRvcnk0ODY5Mjk0","name":"radare2","full_name":"radare/radare2","private":false,"owner":{"login":"radare","id":917142,"node_id":"MDQ6VXNlcjkxNzE0Mg==","avatar_url":"https://avatars1.githubusercontent.com/u/917142?v=4","gravatar_id":"","url":"https://api.github.com/users/radare","html_url":"https://github.com/radare","followers_url":"https://api.github.com/users/radare/followers","following_url":"https://api.github.com/users/radare/following{/other_user}","gists_url":"https://api.github.com/users/radare/gists{/gist_id}","starred_url":"https://api.github.com/users/radare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radare/subscriptions","organizations_url":"https://api.github.com/users/radare/orgs","repos_url":"https://api.github.com/users/radare/repos","events_url":"https://api.github.com/users/radare/events{/privacy}","received_events_url":"https://api.github.com/users/radare/received_events","type":"User","site_admin":false},"html_url":"https://github.com/radare/radare2","description":"unix-like reverse engineering framework and commandline tools security","fork":false,"url":"https://api.github.com/repos/radare/radare2","forks_url":"https://api.github.com/repos/radare/radare2/forks","keys_url":"https://api.github.com/repos/radare/radare2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/radare/radare2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/radare/radare2/teams","hooks_url":"https://api.github.com/repos/radare/radare2/hooks","issue_events_url":"https://api.github.com/repos/radare/radare2/issues/events{/number}","events_url":"https://api.github.com/repos/radare/radare2/events","assignees_url":"https://api.github.com/repos/radare/radare2/assignees{/user}","branches_url":"https://api.github.com/repos/radare/radare2/branches{/branch}","tags_url":"https://api.github.com/repos/radare/radare2/tags","blobs_url":"https://api.github.com/repos/radare/radare2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/radare/radare2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/radare/radare2/git/refs{/sha}","trees_url":"https://api.github.com/repos/radare/radare2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/radare/radare2/statuses/{sha}","languages_url":"https://api.github.com/repos/radare/radare2/languages","stargazers_url":"https://api.github.com/repos/radare/radare2/stargazers","contributors_url":"https://api.github.com/repos/radare/radare2/contributors","subscribers_url":"https://api.github.com/repos/radare/radare2/subscribers","subscription_url":"https://api.github.com/repos/radare/radare2/subscription","commits_url":"https://api.github.com/repos/radare/radare2/commits{/sha}","git_commits_url":"https://api.github.com/repos/radare/radare2/git/commits{/sha}","comments_url":"https://api.github.com/repos/radare/radare2/comments{/number}","issue_comment_url":"https://api.github.com/repos/radare/radare2/issues/comments{/number}","contents_url":"https://api.github.com/repos/radare/radare2/contents/{+path}","compare_url":"https://api.github.com/repos/radare/radare2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/radare/radare2/merges","archive_url":"https://api.github.com/repos/radare/radare2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/radare/radare2/downloads","issues_url":"https://api.github.com/repos/radare/radare2/issues{/number}","pulls_url":"https://api.github.com/repos/radare/radare2/pulls{/number}","milestones_url":"https://api.github.com/repos/radare/radare2/milestones{/number}","notifications_url":"https://api.github.com/repos/radare/radare2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/radare/radare2/labels{/name}","releases_url":"https://api.github.com/repos/radare/radare2/releases{/id}","deployments_url":"https://api.github.com/repos/radare/radare2/deployments","created_at":"2012-07-03T07:42:26Z","updated_at":"2018-09-16T21:25:03Z","pushed_at":"2018-09-16T21:24:58Z","git_url":"git://github.com/radare/radare2.git","ssh_url":"git@github.com:radare/radare2.git","clone_url":"https://github.com/radare/radare2.git","svn_url":"https://github.com/radare/radare2","homepage":"http://www.radare.org/","size":89965,"stargazers_count":8221,"watchers_count":8221,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1616,"mirror_url":null,"archived":false,"open_issues_count":996,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0","node_id":"MDc6TGljZW5zZTEy"},"forks":1616,"open_issues":996,"watchers":8221,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/radare/radare2/pulls/11543"},"html":{"href":"https://github.com/radare/radare2/pull/11543"},"issue":{"href":"https://api.github.com/repos/radare/radare2/issues/11543"},"comments":{"href":"https://api.github.com/repos/radare/radare2/issues/11543/comments"},"review_comments":{"href":"https://api.github.com/repos/radare/radare2/pulls/11543/comments"},"review_comment":{"href":"https://api.github.com/repos/radare/radare2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/radare/radare2/pulls/11543/commits"},"statuses":{"href":"https://api.github.com/repos/radare/radare2/statuses/55427f31bf832beaa4af15c8973a3fc5e36ffc0f"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"ret2libc"}}