[asterisk-commits] mmichelson: branch 1.4 r70808 - /branches/1.4/apps/app_voicemail.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jun 21 14:49:44 CDT 2007


Author: mmichelson
Date: Thu Jun 21 14:49:44 2007
New Revision: 70808

URL: http://svn.digium.com/view/asterisk?view=rev&rev=70808
Log:
When volgain is used don't leave a temporary file behind.
(Closes Issue 8514, Reported and patched by ulogic, code reviewed by Jason Parker)


Modified:
    branches/1.4/apps/app_voicemail.c

Modified: branches/1.4/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_voicemail.c?view=diff&rev=70808&r1=70807&r2=70808
==============================================================================
--- branches/1.4/apps/app_voicemail.c (original)
+++ branches/1.4/apps/app_voicemail.c Thu Jun 21 14:49:44 2007
@@ -1964,19 +1964,21 @@
 		/* 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);
-		if (option_debug > 2)
-			ast_log(LOG_DEBUG, "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;
+			create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp");
+			snprintf(newtmp, sizeof(newtmp), "%s/XXXXXX", tmpdir);
+			tmpfd = mkstemp(newtmp);
 			if (option_debug > 2)
-				ast_log(LOG_DEBUG, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", attach, format, vmu->volgain, mailbox);
+				ast_log(LOG_DEBUG, "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;
+				if (option_debug > 2)
+					ast_log(LOG_DEBUG, "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);
@@ -1986,9 +1988,11 @@
 		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
 }




More information about the asterisk-commits mailing list