4 Star 0 Fork 1

src-oepkgs/alsa-lib-1

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
alsa-lib-1.1.0-pcmhwleak.patch 3.59 KB
一键复制 编辑 原始数据 按行查看 历史
From 0f4f48d37716be0e6ddccb2124c5e09d5bd1cab3 Mon Sep 17 00:00:00 2001
From: Jaroslav Kysela <perex@perex.cz>
Date: Tue, 12 Jan 2016 16:07:16 +0100
Subject: [PATCH 2/3] pcm_hw: fix possible memory leak (coverity)
---
src/pcm/pcm.c | 2 +-
src/pcm/pcm_hw.c | 36 ++++++++++++++++++++----------------
2 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
index cbbc55a..203e7a5 100644
--- a/src/pcm/pcm.c
+++ b/src/pcm/pcm.c
@@ -7512,7 +7512,7 @@ snd_pcm_chmap_query_t **snd_pcm_query_chmaps(snd_pcm_t *pcm)
*/
void snd_pcm_free_chmaps(snd_pcm_chmap_query_t **maps)
{
- snd_pcm_chmap_query_t **p = maps;
+ snd_pcm_chmap_query_t **p;
if (!maps)
return;
for (p = maps; *p; p++)
diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
index 66aec5c..4f4b84b 100644
--- a/src/pcm/pcm_hw.c
+++ b/src/pcm/pcm_hw.c
@@ -1693,12 +1693,14 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
err = snd_config_get_string(n, &str);
if (err < 0) {
SNDERR("Invalid type for %s", id);
- return -EINVAL;
+ err = -EINVAL;
+ goto fail;
}
card = snd_card_get_index(str);
if (card < 0) {
SNDERR("Invalid value for %s", id);
- return card;
+ err = card;
+ goto fail;
}
}
continue;
@@ -1707,7 +1709,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
err = snd_config_get_integer(n, &device);
if (err < 0) {
SNDERR("Invalid type for %s", id);
- return err;
+ goto fail;
}
continue;
}
@@ -1715,7 +1717,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
err = snd_config_get_integer(n, &subdevice);
if (err < 0) {
SNDERR("Invalid type for %s", id);
- return err;
+ goto fail;
}
continue;
}
@@ -1738,7 +1740,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
err = snd_config_get_integer(n, &val);
if (err < 0) {
SNDERR("Invalid type for %s", id);
- return err;
+ goto fail;
}
rate = val;
continue;
@@ -1747,7 +1749,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
err = snd_config_get_string(n, &str);
if (err < 0) {
SNDERR("invalid type for %s", id);
- return err;
+ goto fail;
}
format = snd_pcm_format_value(str);
continue;
@@ -1757,7 +1759,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
err = snd_config_get_integer(n, &val);
if (err < 0) {
SNDERR("Invalid type for %s", id);
- return err;
+ goto fail;
}
channels = val;
continue;
@@ -1767,26 +1769,24 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
chmap = _snd_pcm_parse_config_chmaps(n);
if (!chmap) {
SNDERR("Invalid channel map for %s", id);
- return -EINVAL;
+ goto fail;
}
continue;
}
SNDERR("Unknown field %s", id);
- snd_pcm_free_chmaps(chmap);
- return -EINVAL;
+ err = -EINVAL;
+ goto fail;
}
if (card < 0) {
SNDERR("card is not defined");
- snd_pcm_free_chmaps(chmap);
- return -EINVAL;
+ err = -EINVAL;
+ goto fail;
}
err = snd_pcm_hw_open(pcmp, name, card, device, subdevice, stream,
mode | (nonblock ? SND_PCM_NONBLOCK : 0),
0, sync_ptr_ioctl);
- if (err < 0) {
- snd_pcm_free_chmaps(chmap);
- return err;
- }
+ if (err < 0)
+ goto fail;
if (nonblock && ! (mode & SND_PCM_NONBLOCK)) {
/* revert to blocking mode for read/write access */
snd_pcm_hw_nonblock(*pcmp, 0);
@@ -1810,6 +1810,10 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
hw->chmap_override = chmap;
return 0;
+
+fail:
+ snd_pcm_free_chmaps(chmap);
+ return err;
}
#ifndef DOC_HIDDEN
--
2.4.3
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-oepkgs/alsa-lib-1.git
git@gitee.com:src-oepkgs/alsa-lib-1.git
src-oepkgs
alsa-lib-1
alsa-lib-1
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385