The credentials expiry loop looks at a credential, and if it's expired, frees it and memcpy()s the last credential in the now free place. This results in a memcpy() with source=destination, which technically yields undefined behaviour. Instead of turning it into a memmove, don't copy anything if we deleted the last entry. Signed-off-by: Thomas Rast <trast@xxxxxxxxxxxxxxx> --- Valgrind complained. Sorry for not running it earlier when we were discussing the poll issue... credential-cache--daemon.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) 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)); /* * Stick around 30 seconds in case a new credential * shows up (e.g., because we just removed a failed -- 1.7.7.rc1.366.ge210a6 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html