aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-04-02 18:22:00 +0200
committerMattias Andrée <maandree@kth.se>2021-04-02 18:22:00 +0200
commit384584241f11abb3d4a9cd17840045d9cbe2bfb2 (patch)
treecc96764be93b440bd72d1a5f60a89f32dd38e2f5
parentm (diff)
downloadlibcontacts-384584241f11abb3d4a9cd17840045d9cbe2bfb2.tar.gz
libcontacts-384584241f11abb3d4a9cd17840045d9cbe2bfb2.tar.bz2
libcontacts-384584241f11abb3d4a9cd17840045d9cbe2bfb2.tar.xz
libcontacts_list_contacts: return empty list of contacts if dir is missing
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--libcontacts_list_contacts.c10
1 files changed, 10 insertions, 0 deletions
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;
}