{"thread":{"id":"52411","subject":"[Outreachy] [PATCH] bisect--helper: avoid free-after-use","startedAt":"2019-12-09T08:40:40Z","lastAt":"2019-12-09T11:10:41Z","messageCount":5,"participants":["Miriam Rubio","Johannes Schindelin","Christian Couder","Miriam R."],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"387738","messageId":"20191209084022.18650-1-mirucam@gmail.com","threadId":"52411","inReplyTo":null,"subject":"[Outreachy] [PATCH] bisect--helper: avoid free-after-use","fromName":"Miriam Rubio","fromEmail":"mirucam@gmail.com","sentAt":"2019-12-09T08:40:22Z","receivedAt":"2019-12-09T08:40:40Z","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>\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"},{"id":"387741","messageId":"nycvar.QRO.7.76.6.1912091030310.31080@tvgsbejvaqbjf.bet","threadId":"52411","inReplyTo":"20191209084022.18650-1-mirucam@gmail.com","subject":"Re: [Outreachy] [PATCH] bisect--helper: avoid free-after-use","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-12-09T09:33:17Z","receivedAt":"2019-12-09T09:33:40Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Miriam,\n\njust a little note on the process: the convention on the Git mailing list\nis to use `[PATCH v2]`, `[PATCH v3]`, etc when sending revised patch\nseries. It is even available in `git format-patch`'s options: `-v 2` (see\nhttps://git-scm.com/docs/git-format-patch#Documentation/git-format-patch.txt--vltngt)\n\nOn Mon, 9 Dec 2019, Miriam Rubio wrote:\n\n> From: Tanushree Tumane <tanushreetumane@gmail.com>\n>\n> In 5e82c3dd22a (bisect--helper: `bisect_reset` shell function in C,\n> 2019-01-02), the `git bisect reset` subcommand was ported to C. When the\n> call to `git checkout` failed, an error message was reported to the\n> user.\n>\n> However, this error message used the `strbuf` that had just been\n> released already. Let's switch that around: first use it, then release\n> it.\n>\n> Mentored-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n> Mentored-by: Christian Couder <chriscool@tuxfamily.org>\n> Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com>\n> Signed-off-by: Miriam Rubio <mirucam@gmail.com>\n> ---\n\nACK!\n\nThanks,\nDscho\n\n>  builtin/bisect--helper.c | 7 ++++---\n>  1 file changed, 4 insertions(+), 3 deletions(-)\n>\n> diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c\n> index 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> --\n> 2.21.0 (Apple Git-122.2)\n>\n>\n"},{"id":"387742","messageId":"CAP8UFD2C0uh+e_tH2H=z2RqDwSC7SEu-JoBx3z2KefVND8OqYQ@mail.gmail.com","threadId":"52411","inReplyTo":"20191209084022.18650-1-mirucam@gmail.com","subject":"Re: [Outreachy] [PATCH] bisect--helper: avoid free-after-use","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2019-12-09T10:22:21Z","receivedAt":"2019-12-09T10:22:37Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Hi Miriam,\n\nAs Dscho suggests, next time please use [PATCH v2] or [PATCH v3]\ninstead of [PATCH] if the patch has already been sent, even if the\nsubject has changed.\n\nOn Mon, Dec 9, 2019 at 9:40 AM Miriam Rubio <mirucam@gmail.com> wrote:\n>\n> From: Tanushree Tumane <tanushreetumane@gmail.com>\n>\n> In 5e82c3dd22a (bisect--helper: `bisect_reset` shell function in C,\n> 2019-01-02), the `git bisect reset` subcommand was ported to C. When the\n> call to `git checkout` failed, an error message was reported to the\n> user.\n>\n> However, this error message used the `strbuf` that had just been\n> released already. Let's switch that around: first use it, then release\n> it.\n\nGreat!\n\nI think keeping Tanushree as the author and changing the commit\nmessage and the subject was the right thing to do.\n\n> Mentored-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n> Mentored-by: Christian Couder <chriscool@tuxfamily.org>\n> Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com>\n> Signed-off-by: Miriam Rubio <mirucam@gmail.com>\n> ---\n\nHere (after the line starting with \"---\") you can add comments about\nthe patch. One useful comment here would be to say that this patch is\na new version of\nhttps://public-inbox.org/git/20191208172813.16518-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\nThanks,\nChristian.\n"},{"id":"387743","messageId":"CAN7CjDCU=BPA3n6aDEPEzV8VK=JtYFn5_3CbqYrc5Zpg79m5jw@mail.gmail.com","threadId":"52411","inReplyTo":"CAP8UFD2C0uh+e_tH2H=z2RqDwSC7SEu-JoBx3z2KefVND8OqYQ@mail.gmail.com","subject":"Re: [Outreachy] [PATCH] bisect--helper: avoid free-after-use","fromName":"Miriam R.","fromEmail":"mirucam@gmail.com","sentAt":"2019-12-09T10:36:43Z","receivedAt":"2019-12-09T10:36:56Z","isPatch":true,"sender":{"key":"mirucam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/56339109?v=4"},"body":"El lun., 9 dic. 2019 a las 11:22, Christian Couder\n(<christian.couder@gmail.com>) escribió:\n>\n> Hi Miriam,\n>\n> As Dscho suggests, next time please use [PATCH v2] or [PATCH v3]\n> instead of [PATCH] if the patch has already been sent, even if the\n> subject has changed.\n>\nOk! I take note.\n\n> On Mon, Dec 9, 2019 at 9:40 AM Miriam Rubio <mirucam@gmail.com> wrote:\n> >\n> > From: Tanushree Tumane <tanushreetumane@gmail.com>\n> >\n> > In 5e82c3dd22a (bisect--helper: `bisect_reset` shell function in C,\n> > 2019-01-02), the `git bisect reset` subcommand was ported to C. When the\n> > call to `git checkout` failed, an error message was reported to the\n> > user.\n> >\n> > However, this error message used the `strbuf` that had just been\n> > released already. Let's switch that around: first use it, then release\n> > it.\n>\n> Great!\n>\n> I think keeping Tanushree as the author and changing the commit\n> message and the subject was the right thing to do.\n>\n> > Mentored-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n> > Mentored-by: Christian Couder <chriscool@tuxfamily.org>\n> > Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com>\n> > Signed-off-by: Miriam Rubio <mirucam@gmail.com>\n> > ---\n>\n> Here (after the line starting with \"---\") you can add comments about\n> the patch. One useful comment here would be to say that this patch is\n> a new version of\n> https://public-inbox.org/git/20191208172813.16518-1-mirucam@gmail.com/\n> which itself has been sent previously by Tanushree\n> (https://public-inbox.org/git/64117cde718f0d56ebfa4c30f4d8fe2155f5cf65.1551003074.git.gitgitgadget@gmail.com/).\n>\nOk, I'll resend another one (v2) adding this comments. :)\nThank you.\n\n> Thanks,\n> Christian.\n"},{"id":"387746","messageId":"CAP8UFD1ExQ=hmLK8Sakceh8h9uytF+rVpC_YX3ze0M2LMU+2cw@mail.gmail.com","threadId":"52411","inReplyTo":"CAN7CjDCU=BPA3n6aDEPEzV8VK=JtYFn5_3CbqYrc5Zpg79m5jw@mail.gmail.com","subject":"Re: [Outreachy] [PATCH] bisect--helper: avoid free-after-use","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2019-12-09T11:10:26Z","receivedAt":"2019-12-09T11:10:41Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Mon, Dec 9, 2019 at 11:36 AM Miriam R. <mirucam@gmail.com> wrote:\n\n> > > Mentored-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n> > > Mentored-by: Christian Couder <chriscool@tuxfamily.org>\n> > > Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com>\n> > > Signed-off-by: Miriam Rubio <mirucam@gmail.com>\n> > > ---\n> >\n> > Here (after the line starting with \"---\") you can add comments about\n> > the patch. One useful comment here would be to say that this patch is\n> > a new version of\n> > https://public-inbox.org/git/20191208172813.16518-1-mirucam@gmail.com/\n> > which itself has been sent previously by Tanushree\n> > (https://public-inbox.org/git/64117cde718f0d56ebfa4c30f4d8fe2155f5cf65.1551003074.git.gitgitgadget@gmail.com/).\n> >\n> Ok, I'll resend another one (v2) adding this comments. :)\n\nIt's not a big deal, but there was no need to resend another one, as\nthe comment is there only to help reviewers with extra information\nrelated to where the patch comes from. It will not appear in the\ncommit that will be made from the patch (using `git am`) and I already\ngave the information about where the patch comes from in my reply to\nthe patch.\n"}]}