{"thread":{"id":"52433","subject":"[Outreachy] [PATCH v3] bisect--helper: avoid use-after-free","startedAt":"2019-12-11T19:24:57Z","lastAt":"2019-12-11T19:24:57Z","messageCount":1,"participants":["Miriam Rubio"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"387970","messageId":"20191211192351.7840-1-mirucam@gmail.com","threadId":"52433","inReplyTo":null,"subject":"[Outreachy] [PATCH v3] bisect--helper: avoid use-after-free","fromName":"Miriam Rubio","fromEmail":"mirucam@gmail.com","sentAt":"2019-12-11T19:23:51Z","receivedAt":"2019-12-11T19:24:57Z","isPatch":true,"sender":{"key":"mirucam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/56339109?v=4"},"body":"From: Tanushree Tumane <tanushreetumane@gmail.com>\n\nIn 5e82c3dd22a (bisect--helper: `bisect_reset` shell function in C,\n2019-01-02), the `git bisect reset` subcommand was ported to C. When the\ncall to `git checkout` failed, an error message was reported to the\nuser.\n\nHowever, this error message used the `strbuf` that had just been\nreleased already. Let's switch that around: first use it, then release\nit.\n\nMentored-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\nMentored-by: Christian Couder <chriscool@tuxfamily.org>\nSigned-off-by: Tanushree Tumane <tanushreetumane@gmail.com>\nSigned-off-by: Miriam Rubio <mirucam@gmail.com>\nAcked-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\nThis patch is a new version of\nhttps://public-inbox.org/git/20191209103923.21659-1-mirucam@gmail.com/\nwhich itself has been sent previously by Tanushree\n(https://public-inbox.org/git/64117cde718f0d56ebfa4c30f4d8fe2155f5cf65.1551003074.git.gitgitgadget@gmail.com/).\n\n builtin/bisect--helper.c | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c\nindex 1fbe156e67..3055b2bb50 100644\n--- a/builtin/bisect--helper.c\n+++ b/builtin/bisect--helper.c\n@@ -169,11 +169,12 @@ static int bisect_reset(const char *commit)\n \n \t\targv_array_pushl(&argv, \"checkout\", branch.buf, \"--\", NULL);\n \t\tif (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {\n+\t\t\terror(_(\"could not check out original\"\n+\t\t\t\t\" HEAD '%s'. Try 'git bisect\"\n+\t\t\t\t\" reset <commit>'.\"), branch.buf);\n \t\t\tstrbuf_release(&branch);\n \t\t\targv_array_clear(&argv);\n-\t\t\treturn error(_(\"could not check out original\"\n-\t\t\t\t       \" HEAD '%s'. Try 'git bisect\"\n-\t\t\t\t       \" reset <commit>'.\"), branch.buf);\n+\t\t\treturn -1;\n \t\t}\n \t\targv_array_clear(&argv);\n \t}\n-- \n2.21.0 (Apple Git-122.2)\n\n"}]}