git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/3] fix: use strvec_push_wrapper to prevent ubsan failure

From
lidongyan <502024330056@smail.nju.edu.cn>
Date
May 7, 2025, 12:19 UTC
Message-ID
<1CEABFA7-474C-4253-BB92-E3F153213F5C@smail.nju.edu.cn>
In-Reply-To
<aBsR0CUusW0Fo4Ef@pks.im>
Thank you for your suggestion. I will squash all the commits and include a detailed description in the next submission.
In short, calling parse_options may cause a memory leak when encountering unknown short options. To fix the leak, parse_options can use a user-provided allocation function, so that the user can later free the memory and avoid the leak. I also defined a macro called OPT_UNKNOWN to make it easier for users to pass in their own allocation function.
On the other hand, I think a new file should be added under t/helper/. The reason is that this new file not only serves as a test, but also provides a simple example of using OPT_UNKNOWN, which others can refer to when modifying their own option definitions to avoid memory leaks.
Show 13 quoted lines
> 2025年5月7日 15:54,Patrick Steinhardt <ps@pks.im> 写道:
> 
> On Wed, May 07, 2025 at 02:33:23AM +0000, Lidong Yan via GitGitGadget wrote:
>> From: Lidong Yan <502024330056@smail.nju.edu.cn>
>> 
>> Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn>
> 
> This looks like another fixup-style commit. I assume that all of this
> really should be a single commit, as the latter two commits don't seem
> to do anything new compared to the first commit.
> 
> Patrick
> 
Previous: Patrick SteinhardtNext: Lidong Yan via GitGitGadget
Message 8 of 14 in “fix xstrdup leak in parse_short_opt”
  1. 0/3 fix xstrdup leak in parse_short_optLidong Yan via GitGitGadget, May 7, 2025
  2. 1/3 fix xstrdup leak in parse_short_optLidong Yan via GitGitGadget, May 7, 2025
  3. Patrick SteinhardtMay 7, 2025
  4. 2/3 fix: replace bug where int was incorrectly used as boolLidong Yan via GitGitGadget, May 7, 2025
  5. Patrick SteinhardtMay 7, 2025
  6. 3/3 fix: use strvec_push_wrapper to prevent ubsan failureLidong Yan via GitGitGadget, May 7, 2025
  7. Patrick SteinhardtMay 7, 2025
  8. lidongyanMay 7, 2025
  9. parse-options: fix xstrdup leak in parse_options_step parse-options:984Lidong Yan via GitGitGadget, May 7, 2025
  10. Patrick SteinhardtMay 9, 2025
  11. lidongyanMay 9, 2025
  12. Phillip WoodMay 9, 2025
  13. lidongyanMay 9, 2025
  14. parse-options: fix memory leak when calling `parse_options`Lidong Yan via GitGitGadget, May 9, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.