src/etpan_mime.c
changeset 157 63eb5372f2ef
parent 156 0d9aec90828f
child 159 ad6d0993d1ab
     1.1 --- a/src/etpan_mime.c	Sun Mar 29 12:03:09 2015 +0200
     1.2 +++ b/src/etpan_mime.c	Sun Mar 29 13:54:38 2015 +0200
     1.3 @@ -8,9 +8,7 @@
     1.4  #include <string.h>
     1.5  #include <stdlib.h>
     1.6  #include <assert.h>
     1.7 -
     1.8 -
     1.9 -time_t mail_mkgmtime(struct tm * tmp);
    1.10 +#include <errno.h>
    1.11  
    1.12  #define MAX_MESSAGE_ID 512
    1.13  
    1.14 @@ -630,7 +628,7 @@
    1.15      return NULL;
    1.16  }
    1.17  
    1.18 -bool parameter_has_value(
    1.19 +static bool parameter_has_value(
    1.20          struct mailmime_content *content,       
    1.21          const char *name,
    1.22          const char *value
    1.23 @@ -712,8 +710,10 @@
    1.24  
    1.25      assert(content);
    1.26  
    1.27 -    if (content->ct_subtype == NULL)
    1.28 +    if (content->ct_subtype == NULL) {
    1.29 +        errno = EINVAL;
    1.30          return NULL;
    1.31 +    }
    1.32  
    1.33      if (content->ct_type && content->ct_type->tp_data.tp_discrete_type) {
    1.34          size_t len;
    1.35 @@ -739,23 +739,27 @@
    1.36                  _type = "extension";
    1.37                  break;
    1.38              default:
    1.39 +                errno = EINVAL;
    1.40                  return NULL;
    1.41          }
    1.42  
    1.43          len = strlen(_type) + 1 + strlen(content->ct_subtype) + 1;
    1.44          type = calloc(1, len);
    1.45          assert(type);
    1.46 -        // BUG: out of memory cannot be signaled
    1.47 -        if (type == NULL)
    1.48 +        if (type == NULL) {
    1.49 +            errno = ENOMEM;
    1.50              return NULL;
    1.51 +        }
    1.52  
    1.53          strcpy(type, _type);
    1.54          strcat(type, "/");
    1.55          strcat(type, content->ct_subtype);
    1.56  
    1.57 +        errno = 0;
    1.58          return type;
    1.59      }
    1.60  
    1.61 +    errno = EINVAL;
    1.62      return NULL;
    1.63  }
    1.64