X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=sbr%2Ffolder_read.c;h=8e3a3ffa7e6648cbc3c917a2fc5aef867e675214;hb=81a21a9a97d8633f6d6231e31fdb6e328d0d3ff2;hp=b5b3f9d58792eb8c769d135554d3f976bce38bdb;hpb=6c42153ad9362cc676ea66563bf400d7511b3b68;p=mmh diff --git a/sbr/folder_read.c b/sbr/folder_read.c index b5b3f9d..8e3a3ff 100644 --- a/sbr/folder_read.c +++ b/sbr/folder_read.c @@ -10,6 +10,7 @@ */ #include +#include /* We allocate the `mi' array 1024 elements at a time */ #define NUMMSGS 1024 @@ -44,8 +45,7 @@ folder_read (char *name) } /* Allocate the main structure for folder information */ - if (!(mp = (struct msgs *) malloc ((size_t) sizeof(*mp)))) - adios (NULL, "unable to allocate folder storage"); + mp = (struct msgs *) mh_xmalloc ((size_t) sizeof(*mp)); clear_folder_flags (mp); mp->foldpath = name; @@ -57,7 +57,7 @@ folder_read (char *name) mp->numsel = 0; mp->nummsg = 0; - if (access (name, W_OK) == -1 || st.st_uid != getuid()) + if (access (name, W_OK) == -1) set_readonly (mp); prefix_len = strlen(BACKUP_PREFIX); @@ -66,11 +66,10 @@ folder_read (char *name) * name of the messages in this folder. */ len = NUMMSGS; - if (!(mi = (int *) malloc ((size_t) (len * sizeof(*mi))))) - adios (NULL, "unable to allocate storage"); + mi = (int *) mh_xmalloc ((size_t) (len * sizeof(*mi))); while ((dp = readdir (dd))) { - if ((msgnum = m_atoi (dp->d_name))) { + if ((msgnum = m_atoi (dp->d_name)) && msgnum > 0) { /* * Check if we need to allocate more * temporary elements for message names. @@ -138,8 +137,7 @@ folder_read (char *name) /* * Allocate space for status of each message. */ - if (!(mp->msgstats = malloc (MSGSTATSIZE(mp, mp->lowoff, mp->hghoff)))) - adios (NULL, "unable to allocate storage for msgstats"); + mp->msgstats = mh_xmalloc (MSGSTATSIZE(mp, mp->lowoff, mp->hghoff)); /* * Clear all the flag bits for all the message