From 4c0b91a5a045e3f03a049320d26542ab9fec4745 Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Wed, 3 Jun 2009 01:05:34 +0000 Subject: libglusterfs: Add empty and NULL dirents list checks These checks are needed in case a higher layer intends to delink the dirent list and passes a NULL pointer to fop_readdir_cbk_stub for the entries parameter. Consequently, the gf_dirent_free must guard against an empty list because the stub that is passed to it mgiht have an empty dirent list. Signed-off-by: Anand V. Avati --- libglusterfs/src/gf-dirent.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libglusterfs/src/gf-dirent.c') diff --git a/libglusterfs/src/gf-dirent.c b/libglusterfs/src/gf-dirent.c index 2023c19836f..b321dfc10e0 100644 --- a/libglusterfs/src/gf-dirent.c +++ b/libglusterfs/src/gf-dirent.c @@ -76,6 +76,12 @@ gf_dirent_free (gf_dirent_t *entries) gf_dirent_t *entry = NULL; gf_dirent_t *tmp = NULL; + if (!entries) + return; + + if (list_empty (&entries->list)) + return; + list_for_each_entry_safe (entry, tmp, &entries->list, list) { list_del (&entry->list); FREE (entry); -- cgit