Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 304138) +++ apps/app_voicemail.c (working copy) @@ -3592,7 +3592,8 @@ char *ctype = (!strcasecmp(format, "ogg")) ? "application/" : "audio/x-"; char tmpdir[256], newtmp[256]; int tmpfd = -1; - + int soxstatus = 0; + if (vmu->volgain < -.001 || vmu->volgain > .001) { create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp"); snprintf(newtmp, sizeof(newtmp), "%s/XXXXXX", tmpdir); @@ -3601,7 +3602,6 @@ if (option_debug > 2) ast_log(LOG_DEBUG, "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; @@ -3624,7 +3624,9 @@ base_encode(fname, p); fprintf(p, ENDL "--%s--" ENDL "." ENDL, bound); if (tmpfd > -1) { - unlink(fname); + if (soxstatus == 0) { + unlink(fname); + } close(tmpfd); unlink(newtmp); }