{"action":"closed","issue":{"url":"https://api.github.com/repos/Arondight/sudodev/issues/4","labels_url":"https://api.github.com/repos/Arondight/sudodev/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/Arondight/sudodev/issues/4/comments","events_url":"https://api.github.com/repos/Arondight/sudodev/issues/4/events","html_url":"https://github.com/Arondight/sudodev/issues/4","id":115419145,"number":4,"title":"内存泄露","user":{"login":"abbycin","id":6814167,"avatar_url":"https://avatars.githubusercontent.com/u/6814167?v=3","gravatar_id":"","url":"https://api.github.com/users/abbycin","html_url":"https://github.com/abbycin","followers_url":"https://api.github.com/users/abbycin/followers","following_url":"https://api.github.com/users/abbycin/following{/other_user}","gists_url":"https://api.github.com/users/abbycin/gists{/gist_id}","starred_url":"https://api.github.com/users/abbycin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abbycin/subscriptions","organizations_url":"https://api.github.com/users/abbycin/orgs","repos_url":"https://api.github.com/users/abbycin/repos","events_url":"https://api.github.com/users/abbycin/events{/privacy}","received_events_url":"https://api.github.com/users/abbycin/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-06T02:06:50Z","updated_at":"2015-11-06T11:43:27Z","closed_at":"2015-11-06T11:43:27Z","body":"没有插入外部设备， 执行 `valgrind --leak-check=full --show-leak-kinds=all ./sudodev add`    \r\n部分输出：   \r\n\r\n```plain\r\n==7931== HEAP SUMMARY:\r\n==7931==     in use at exit: 8,200 bytes in 2 blocks\r\n==7931==   total heap usage: 106 allocs, 104 frees, 126,457 bytes allocated\r\n==7931== \r\n==7931== 8 bytes in 1 blocks are still reachable in loss record 1 of 2\r\n==7931==    at 0x4C29110: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)\r\n==7931==    by 0x4017D5: add (sudodev.c:193)\r\n==7931==    by 0x402739: attempt (sudodev.c:559)\r\n==7931==    by 0x40283F: main (sudodev.c:604)\r\n==7931== \r\n==7931== 8,192 bytes in 1 blocks are definitely lost in loss record 2 of 2\r\n==7931==    at 0x4C29110: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)\r\n==7931==    by 0x403103: devs (devs.c:243)\r\n==7931==    by 0x40171E: add (sudodev.c:173)\r\n==7931==    by 0x402739: attempt (sudodev.c:559)\r\n==7931==    by 0x40283F: main (sudodev.c:604)\r\n==7931== \r\n==7931== LEAK SUMMARY:\r\n==7931==    definitely lost: 8,192 bytes in 1 blocks\r\n==7931==    indirectly lost: 0 bytes in 0 blocks\r\n==7931==      possibly lost: 0 bytes in 0 blocks\r\n==7931==    still reachable: 8 bytes in 1 blocks\r\n==7931==         suppressed: 0 bytes in 0 blocks\r\n==7931== \r\n==7931== For counts of detected and suppressed errors, rerun with: -v\r\n==7931== Use --track-origins=yes to see where uninitialised values come from\r\n==7931== ERROR SUMMARY: 12 errors from 4 contexts (suppressed: 0 from 0)\r\n\r\n```\r\n\r\n在`sudodev.c`中的add()函数中有一段代码  \r\n\r\n```c\r\nif (count < 1)\r\n{\r\n    say (mode, MSG_W, \"No available device found\\n\");\r\n    return 1;\r\n} \r\n``` \r\n\r\n建议将`return 1` 改为 `goto CLEAN`"}}