diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 188349b458add47e0e1dd24f461142bd8ecc9eb1..52e5c5387d9c7744b1c94950b2fb6b43e1bc6435 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -2364,7 +2364,7 @@ struct leave_vm_options { static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_options *options) { - char txtfile[256]; + char tmptxtfile[256], txtfile[256]; char callerid[256]; FILE *txt; int res = 0; @@ -2561,7 +2561,8 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_ /* Store information */ snprintf(txtfile, sizeof(txtfile), "%s.txt", fn); - txt = fopen(txtfile, "w+"); + snprintf(tmptxtfile, sizeof(tmptxtfile), "%s.txt.tmp", fn); + txt = fopen(tmptxtfile, "w+"); if (txt) { get_date(date, sizeof(date)); fprintf(txt, @@ -2601,6 +2602,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_ if (txt) { fprintf(txt, "duration=%d\n", duration); fclose(txt); + rename(tmptxtfile, txtfile); } if (duration < vmminmessage) {