merging
authorVolker Birk <vb@pep-project.org>
Wed, 14 Oct 2015 01:58:52 +0200
changeset 376295bb70722ef
parent 375 66e48c55cd7a
parent 374 a26015b998e8
child 377 ef2b8046cb3c
merging
     1.1 --- a/src/mime.c	Wed Oct 14 01:58:15 2015 +0200
     1.2 +++ b/src/mime.c	Wed Oct 14 01:58:52 2015 +0200
     1.3 @@ -51,21 +51,21 @@
     1.4      int r;
     1.5  
     1.6      char *template;
     1.7 -    char *envTmp = getenv("TEMP");
     1.8 +    char *env_tmp = getenv("TEMP");
     1.9  
    1.10 -    if(envTmp){
    1.11 -        int tmpL = strlen(envTmp);
    1.12 -        int needSep = envTmp[tmpL-1] == PATH_SEP;
    1.13 -        template = calloc(1, tmpL + 
    1.14 -                             (needSep ? 1 : 0) +
    1.15 +    if(env_tmp){
    1.16 +        int tmp_l = strlen(env_tmp);
    1.17 +        int need_sep = (env_tmp[tmp_l-1] != PATH_SEP);
    1.18 +        template = calloc(1, tmp_l + 
    1.19 +                             (need_sep ? 1 : 0) +
    1.20                               sizeof(TMP_TEMPLATE));
    1.21          if (template == NULL)
    1.22              goto enomem;
    1.23  
    1.24 -        memcpy(template, envTmp, tmpL);
    1.25 -        if(needSep)
    1.26 -            template[tmpL] = PATH_SEP;
    1.27 -        memcpy(template + tmpL + (needSep ? 1 : 0), TMP_TEMPLATE, sizeof(TMP_TEMPLATE));
    1.28 +        memcpy(template, env_tmp, tmp_l);
    1.29 +        if(need_sep)
    1.30 +            template[tmp_l] = PATH_SEP;
    1.31 +        memcpy(template + tmp_l + (need_sep ? 1 : 0), TMP_TEMPLATE, sizeof(TMP_TEMPLATE));
    1.32  
    1.33      }else{
    1.34          template = strdup("/tmp/" TMP_TEMPLATE);