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

Re: [PATCH 2/2] check_expirations: don't copy over same element

From
Jeff King <peff@peff.net>
Date
Sep 16, 2011, 15:47 UTC
Message-ID
<20110916154718.GA13740@sigill.intra.peff.net>
In-Reply-To
<29010bf6134beb20efca498e7b4f7a9d9bdb21a6.1316173346.git.trast@student.ethz.ch>
On Fri, Sep 16, 2011 at 01:51:35PM +0200, Thomas Rast wrote:
Show 11 quoted lines
> diff --git a/credential-cache--daemon.c b/credential-cache--daemon.c
> index d6769b1..128c5ce 100644
> --- a/credential-cache--daemon.c
> +++ b/credential-cache--daemon.c
> @@ -77,7 +77,8 @@ static int check_expirations(void)
>  			free(entries[i].item.unique);
>  			free(entries[i].item.username);
>  			free(entries[i].item.password);
> -			memcpy(&entries[i], &entries[entries_nr], sizeof(*entries));
> +			if (i != entries_nr)
> +				memcpy(&entries[i], &entries[entries_nr], sizeof(*entries));

Thanks. I even remember while writing this loop considering the case of (i == entries_nr), but decided it didn't need special-casing. But I obviously forgot about memcpy.

Both this and the prior patch are:
Acked-by: Jeff King <peff@peff.net>
-Peff
Previous: Thomas RastNext: Junio C Hamano
Message 7 of 12 in “credential helper super fun pak”
  1. 0/5 credential helper super fun pakJeff King, Sep 14, 2011
  2. 1/5 docs: minor tweaks to credentials APIJeff King, Sep 14, 2011
  3. 2/5 credential-cache: fix expiration calculation corner casesJeff King, Sep 14, 2011
  4. Thomas RastSep 15, 2011
  5. 1/2 t0300: add missing EOF terminator for <<Thomas Rast, Sep 16, 2011
  6. 2/2 check_expirations: don't copy over same elementThomas Rast, Sep 16, 2011
  7. Jeff KingSep 16, 2011
  8. Junio C HamanoSep 18, 2011
  9. 3/5 t0300: make askpass tests a little more robustJeff King, Sep 14, 2011
  10. 4/5 t0300: make alternate username tests more robustJeff King, Sep 14, 2011
  11. 5/5 credential-store: use a better storage formatJeff King, Sep 14, 2011
  12. Junio C HamanoSep 14, 2011

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.