diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 67305818266c07a53ccc0fce4324fa50b57fa2a3..7d9917d7e7f67d2da51f79336b0035e8d3ae72e9 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -6006,12 +6006,13 @@ static int msg_create_from_file(struct ast_vm_recording_data *recdata)
 	if ((recording_fs = ast_readfile(recdata->recording_file, recdata->recording_ext, NULL, 0, 0, VOICEMAIL_DIR_MODE))) {
 		if (!ast_seekstream(recording_fs, 0, SEEK_END)) {
 			long framelength = ast_tellstream(recording_fs);
-			struct ast_format result;
+			struct ast_format result = {0,};
 			/* XXX This use of ast_getformatbyname seems incorrect here. The file extension does not necessarily correspond
 			 * to the name of the format. For instance, if "raw" were passed in, I don't think ast_getformatbyname would
 			 * find the slinear format
 			 */
-			duration = (int) (framelength / ast_format_rate(ast_getformatbyname(recdata->recording_ext, &result)));
+			ast_getformatbyname(recdata->recording_ext, &result);
+			duration = (int) (framelength / ast_format_rate(&result));
 		}
 	}