From: Atharva Raykar Date: Fri, 06 Aug 2021 11:33:36 GMT Subject: Re: [GSoC] [PATCH v2 6/9] submodule--helper: convert the bulk of cmd_add() to C Message-ID: In-Reply-To: Đoàn Trần Công Danh writes: > On 2021-08-05 13:10:51+0530, Atharva Raykar wrote: >> [...] >> + add_data.sm_path = xstrdup(argv[1]); > > add_data.sm_path is allocated in this block (regardless of legs). > >> [...] >> + if ((exit_code = pipe_command(&cp, NULL, 0, NULL, 0, &sb, 0))) { >> + strbuf_complete_line(&sb); >> + fputs(sb.buf, stderr); >> + return exit_code; > > But, we don't free it when return from here. > >> [...] >> + >> + if (add_submodule(&add_data)) >> + return 1; > > And here. > >> + configure_added_submodule(&add_data); >> + free(add_data.sm_path); > > However, it will be free()-d here, is it intended? Yeah I meant to have it free()'d wherever possible, although I suppose it isn't strictly necessary since we exit. > I think we may use UNLEAK above (for now) because we will exit process > after this function. > > However, I anticipated we may need to do more stuffs after this > function in the future. Right. So it's better I ensure that it's freed properly everywhere. >> [...] >> -- >> 2.32.0 >>