diff --git a/apps/app_minivm.c b/apps/app_minivm.c
index 62b04887910c94e743407877ec0bb6a41d85e3cd..f2ee5ee7e07b1f0143a79830ac19f127139d7b3b 100644
--- a/apps/app_minivm.c
+++ b/apps/app_minivm.c
@@ -1277,6 +1277,8 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
 		tmpfd = mkstemp(newtmp);
 		if (tmpfd < 0) {
 			ast_log(LOG_WARNING, "Failed to create temporary file for volgain: %d\n", errno);
+			ast_free(str1);
+			ast_free(str2);
 			return -1;
 		}
 		snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, filename, format, newtmp, format);