From 74c22f758c997b2d4da42c80e45055e3f70d3a57 Mon Sep 17 00:00:00 2001 From: Milanka Ringwald Date: Fri, 22 Dec 2017 23:12:32 +0100 Subject: [PATCH] wav writter: check if wav file exists, prevent access to NULL pointer --- platform/posix/wav_util.c | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/posix/wav_util.c b/platform/posix/wav_util.c index 2263082c4..09f3b8f6e 100644 --- a/platform/posix/wav_util.c +++ b/platform/posix/wav_util.c @@ -133,6 +133,7 @@ int wav_writer_open(const char * filepath, int num_channels, int sampling_freque } int wav_writer_close(void){ + if (!wav_writer_state.wav_file) return 0; rewind(wav_writer_state.wav_file); write_wav_header(wav_writer_state.wav_file, wav_writer_state.total_num_samples, wav_writer_state.num_channels, wav_writer_state.sampling_frequency);