Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 304138) +++ apps/app_voicemail.c (working copy) @@ -4690,6 +4690,7 @@ char fname[256]; char tmpcmd[256]; int tmpfd = -1; + int soxstatus = 0; /* Eww. We want formats to tell us their own MIME type */ char *ctype = (!strcasecmp(format, "ogg")) ? "application/" : "audio/x-"; @@ -4701,7 +4702,6 @@ chmod(newtmp, VOICEMAIL_FILE_MODE & ~my_umask); ast_debug(3, "newtmp: %s\n", newtmp); if (tmpfd > -1) { - int soxstatus; snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, attach, format, newtmp, format); if ((soxstatus = ast_safe_system(tmpcmd)) == 0) { attach = newtmp; @@ -4729,7 +4729,9 @@ if (last) fprintf(p, ENDL ENDL "--%s--" ENDL "." ENDL, bound); if (tmpfd > -1) { - unlink(fname); + if (soxstatus == 0) { + unlink(fname); + } close(tmpfd); unlink(newtmp); }