1 Star 0 Fork 1

BrainZhao/alsa-lib-1

forked from src-oepkgs/alsa-lib-1 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
alsa-lib-1.1.0-ctlelemassert.patch 4.26 KB
一键复制 编辑 原始数据 按行查看 历史
From 822e781a47267b6efe70260486927f895b83ed84 Mon Sep 17 00:00:00 2001
From: Jaroslav Kysela <perex@perex.cz>
Date: Tue, 12 Jan 2016 15:58:25 +0100
Subject: [PATCH 1/3] control: add missing asserts to ctl_elem_set functions
---
src/control/control.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/control/control.c b/src/control/control.c
index 4a28cf6..8504d07 100644
--- a/src/control/control.c
+++ b/src/control/control.c
@@ -2497,7 +2497,7 @@ void snd_ctl_elem_value_set_index(snd_ctl_elem_value_t *obj, unsigned int val)
int snd_ctl_elem_value_get_boolean(const snd_ctl_elem_value_t *obj, unsigned int idx)
{
assert(obj);
- assert(idx < sizeof(obj->value.integer.value) / sizeof(obj->value.integer.value[0]));
+ assert(idx < ARRAY_SIZE(obj->value.integer.value));
return obj->value.integer.value[idx];
}
@@ -2510,7 +2510,7 @@ int snd_ctl_elem_value_get_boolean(const snd_ctl_elem_value_t *obj, unsigned int
long snd_ctl_elem_value_get_integer(const snd_ctl_elem_value_t *obj, unsigned int idx)
{
assert(obj);
- assert(idx < sizeof(obj->value.integer.value) / sizeof(obj->value.integer.value[0]));
+ assert(idx < ARRAY_SIZE(obj->value.integer.value));
return obj->value.integer.value[idx];
}
@@ -2523,7 +2523,7 @@ long snd_ctl_elem_value_get_integer(const snd_ctl_elem_value_t *obj, unsigned in
long long snd_ctl_elem_value_get_integer64(const snd_ctl_elem_value_t *obj, unsigned int idx)
{
assert(obj);
- assert(idx < sizeof(obj->value.integer64.value) / sizeof(obj->value.integer64.value[0]));
+ assert(idx < ARRAY_SIZE(obj->value.integer64.value));
return obj->value.integer64.value[idx];
}
@@ -2536,7 +2536,7 @@ long long snd_ctl_elem_value_get_integer64(const snd_ctl_elem_value_t *obj, unsi
unsigned int snd_ctl_elem_value_get_enumerated(const snd_ctl_elem_value_t *obj, unsigned int idx)
{
assert(obj);
- assert(idx < sizeof(obj->value.enumerated.item) / sizeof(obj->value.enumerated.item[0]));
+ assert(idx < ARRAY_SIZE(obj->value.enumerated.item));
return obj->value.enumerated.item[idx];
}
@@ -2549,7 +2549,7 @@ unsigned int snd_ctl_elem_value_get_enumerated(const snd_ctl_elem_value_t *obj,
unsigned char snd_ctl_elem_value_get_byte(const snd_ctl_elem_value_t *obj, unsigned int idx)
{
assert(obj);
- assert(idx < sizeof(obj->value.bytes.data));
+ assert(idx < ARRAY_SIZE(obj->value.bytes.data));
return obj->value.bytes.data[idx];
}
@@ -2562,6 +2562,7 @@ unsigned char snd_ctl_elem_value_get_byte(const snd_ctl_elem_value_t *obj, unsig
void snd_ctl_elem_value_set_boolean(snd_ctl_elem_value_t *obj, unsigned int idx, long val)
{
assert(obj);
+ assert(idx < ARRAY_SIZE(obj->value.integer.value));
obj->value.integer.value[idx] = val;
}
@@ -2574,6 +2575,7 @@ void snd_ctl_elem_value_set_boolean(snd_ctl_elem_value_t *obj, unsigned int idx,
void snd_ctl_elem_value_set_integer(snd_ctl_elem_value_t *obj, unsigned int idx, long val)
{
assert(obj);
+ assert(idx < ARRAY_SIZE(obj->value.integer.value));
obj->value.integer.value[idx] = val;
}
@@ -2586,6 +2588,7 @@ void snd_ctl_elem_value_set_integer(snd_ctl_elem_value_t *obj, unsigned int idx,
void snd_ctl_elem_value_set_integer64(snd_ctl_elem_value_t *obj, unsigned int idx, long long val)
{
assert(obj);
+ assert(idx < ARRAY_SIZE(obj->value.integer64.value));
obj->value.integer64.value[idx] = val;
}
@@ -2598,6 +2601,7 @@ void snd_ctl_elem_value_set_integer64(snd_ctl_elem_value_t *obj, unsigned int id
void snd_ctl_elem_value_set_enumerated(snd_ctl_elem_value_t *obj, unsigned int idx, unsigned int val)
{
assert(obj);
+ assert(idx < ARRAY_SIZE(obj->value.enumerated.item));
obj->value.enumerated.item[idx] = val;
}
@@ -2610,6 +2614,7 @@ void snd_ctl_elem_value_set_enumerated(snd_ctl_elem_value_t *obj, unsigned int i
void snd_ctl_elem_value_set_byte(snd_ctl_elem_value_t *obj, unsigned int idx, unsigned char val)
{
assert(obj);
+ assert(idx < ARRAY_SIZE(obj->value.bytes.data));
obj->value.bytes.data[idx] = val;
}
@@ -2622,7 +2627,7 @@ void snd_ctl_elem_value_set_byte(snd_ctl_elem_value_t *obj, unsigned int idx, un
void snd_ctl_elem_set_bytes(snd_ctl_elem_value_t *obj, void *data, size_t size)
{
assert(obj);
- if (size >= sizeof(obj->value.bytes.data)) {
+ if (size >= ARRAY_SIZE(obj->value.bytes.data)) {
assert(0);
return;
}
--
2.4.3
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/brainzhao/alsa-lib-1.git
git@gitee.com:brainzhao/alsa-lib-1.git
brainzhao
alsa-lib-1
alsa-lib-1
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385