diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 17afc5f9b60d2276d3bc0dd02709c578c83d140a..a9b3d3d2752a36589a336f786d1ee8fddab615a8 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -5259,7 +5259,8 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
 		return -1;
 	}
 
-	ext = ast_strdupa(ext);
+	ast_str_set(&tmp, 0, "%s", ext);
+	ext = ast_str_buffer(tmp);
 	if ((context = strchr(ext, '@'))) {
 		*context++ = '\0';
 		tmpptr = strchr(context, '&');