From f563268fac3fcb83f89362cacfd417c452d0a9ea Mon Sep 17 00:00:00 2001 From: Abramo Bagnara Date: Wed, 6 Jun 2001 14:19:40 +0000 Subject: [PATCH] Fixed strdup --- src/pcm/pcm_file.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pcm/pcm_file.c b/src/pcm/pcm_file.c index d49c2a1e..b28c26a1 100644 --- a/src/pcm/pcm_file.c +++ b/src/pcm/pcm_file.c @@ -422,8 +422,9 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, const char *fname, int close(fd); return -ENOMEM; } - - file->fname = strdup(fname); + + if (fname) + file->fname = strdup(fname); file->fd = fd; file->format = format; file->slave = slave; @@ -431,6 +432,8 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, const char *fname, int pcm = calloc(1, sizeof(snd_pcm_t)); if (!pcm) { + if (fname) + free(file->fname); free(file); return -ENOMEM; } -- 2.47.1