From 9ec09d5124bc1d1c081d8c910ace663e1f398649 Mon Sep 17 00:00:00 2001 From: Taylor Holberton Date: Wed, 26 Jun 2019 18:01:59 -0400 Subject: pcm-readi: Fixed segfault in failure recovery --- examples/pcm-readi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'examples') diff --git a/examples/pcm-readi.c b/examples/pcm-readi.c index 5b85ca6..8722b41 100644 --- a/examples/pcm-readi.c +++ b/examples/pcm-readi.c @@ -23,11 +23,11 @@ static size_t read_frames(void **frames) struct pcm *pcm = pcm_open(card, device, flags, &config); if (pcm == NULL) { fprintf(stderr, "failed to allocate memory for PCM\n"); - return EXIT_FAILURE; + return 0; } else if (!pcm_is_ready(pcm)){ pcm_close(pcm); fprintf(stderr, "failed to open PCM\n"); - return EXIT_FAILURE; + return 0; } unsigned int frame_size = pcm_frames_to_bytes(pcm, 1); @@ -37,7 +37,7 @@ static size_t read_frames(void **frames) if (*frames == NULL) { fprintf(stderr, "failed to allocate frames\n"); pcm_close(pcm); - return EXIT_FAILURE; + return 0; } int read_count = pcm_readi(pcm, *frames, frames_per_sec); @@ -63,8 +63,8 @@ static int write_file(const void *frames, size_t size) int main(void) { - void *frames; - size_t size; + void *frames = NULL; + size_t size = 0; size = read_frames(&frames); if (size == 0) { -- cgit v1.2.3