fix a memory leak after strdup() failure

This commit is contained in:
Nedko Arnaudov 2011-05-16 01:40:57 +03:00
parent b9f820573e
commit 1612b562af
1 changed files with 10 additions and 1 deletions

View File

@ -2,7 +2,7 @@
/*
* LADI Session Handler (ladish)
*
* Copyright (C) 2010 Nedko Arnaudov <nedko@arnaudov.name>
* Copyright (C) 2010, 2011 Nedko Arnaudov <nedko@arnaudov.name>
*
**************************************************************************
* This file contains implementation of the recent items store
@ -137,6 +137,15 @@ ladish_recent_store_load(
if (store_ptr->items[i] == NULL)
{
log_error("strdup(\"%s\") failed.", temp_ptr);
/* free the already duplicated items */
while (i > 0)
{
i--;
free(store_ptr->items[i]);
store_ptr->items[i] = NULL;
}
goto free;
}