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

Re: [PATCH] use xstrdup, not strdup in ll-merge.c

From
Alex Riesen <raa.lkml@gmail.com>
Date
Jun 15, 2009, 15:21 UTC
Message-ID
<81b0412b0906150821x30eb621ctcddc7691192b5270@mail.gmail.com>
In-Reply-To
<20090615142648.GV16497@spearce.org>
2009/6/15 Shawn O. Pearce <spearce@spearce.org>:
Show 12 quoted lines
> Alex Riesen <raa.lkml@gmail.com> wrote:
>> As much as I'd like to know as much as possible about why something
>> failed, I can't make a failure handling automatically simple (given the tools).
>> I do suggest using goto to handle this particular OOM (below), but it looks
>> almost too ugly. Maybe I am just paranoid, and am overdoing this particular
>> case.
>
> Yes, this is horrible.  Its a huge amount of code for checking a
> strdup failure that is unlikely to occur out of a configuration file.
>
> Really, how big is that config file?  It can't be so large that a
> strdup() is likely to run out of memory pulling a value from it.

Oh, I don't worry about config files being too big (it is noticeable without this checks). I'm worried about our bugs triggering the conditions where allocation routines return NULL, like heap corruption which is hard to notice without valgrind.

>> The "goto oom" patch:
>
> NAK.  We don't do this anywhere else in git.  Please don't start now.

We'll have to start paying more attention to memory management sometime. Although, this particular case may be not the best case for it.

Previous: Shawn O. Pearce
Message 10 of 10 in “use xstrdup, not strdup in ll-merge.c”
  1. use xstrdup, not strdup in ll-merge.cJim Meyering, Jun 14, 2009
  2. Alex RiesenJun 14, 2009
  3. Jim MeyeringJun 15, 2009
  4. Alex RiesenJun 15, 2009
  5. Jim MeyeringJun 15, 2009
  6. Alex RiesenJun 15, 2009
  7. Jim MeyeringJun 15, 2009
  8. Alex RiesenJun 15, 2009
  9. Shawn O. PearceJun 15, 2009
  10. Alex RiesenJun 15, 2009

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.