diff options
-rw-r--r-- | apps/app_voicemail.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 42ef554a4..167f10849 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -2095,17 +2095,19 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in /* Eww. We want formats to tell us their own MIME type */ char *ctype = (!strcasecmp(format, "ogg")) ? "application/" : "audio/x-"; char tmpdir[256], newtmp[256]; - int tmpfd; + int tmpfd = -1; - create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp"); - snprintf(newtmp, sizeof(newtmp), "%s/XXXXXX", tmpdir); - tmpfd = mkstemp(newtmp); - ast_debug(3, "newtmp: %s\n", newtmp); if (vmu->volgain < -.001 || vmu->volgain > .001) { - snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, attach, format, newtmp, format); - ast_safe_system(tmpcmd); - attach = newtmp; - ast_debug(3, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", attach, format, vmu->volgain, mailbox); + create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp"); + snprintf(newtmp, sizeof(newtmp), "%s/XXXXXX", tmpdir); + tmpfd = mkstemp(newtmp); + ast_debug(3, "newtmp: %s\n", newtmp); + if (tmpfd > -1) { + snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, attach, format, newtmp, format); + ast_safe_system(tmpcmd); + attach = newtmp; + ast_debug(3, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", attach, format, vmu->volgain, mailbox); + } } fprintf(p, "--%s" ENDL, bound); fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"" ENDL, ctype, format, msgnum + 1, format); @@ -2115,9 +2117,11 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in snprintf(fname, sizeof(fname), "%s.%s", attach, format); base_encode(fname, p); fprintf(p, ENDL "--%s--" ENDL "." ENDL, bound); - if (tmpfd > -1) + if (tmpfd > -1) { + unlink(fname); close(tmpfd); - unlink(newtmp); + unlink(newtmp); + } } #undef ENDL } |