From 384584241f11abb3d4a9cd17840045d9cbe2bfb2 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 2 Apr 2021 18:22:00 +0200 Subject: libcontacts_list_contacts: return empty list of contacts if dir is missing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libcontacts_list_contacts.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libcontacts_list_contacts.c b/libcontacts_list_contacts.c index e4794f0..fbf56ee 100644 --- a/libcontacts_list_contacts.c +++ b/libcontacts_list_contacts.c @@ -20,6 +20,16 @@ libcontacts_list_contacts(char ***idsp, const struct passwd *user) dir = opendir(dirnam); if (!dir) { + if (errno == ENOENT) { + errno = saved_errno; + new = malloc(sizeof(**idsp)); + if (new) { + *idsp = new; + **idsp = NULL; + free(dirnam); + return 0; + } + } free(dirnam); return -1; } -- cgit v1.2.3-70-g09d2