mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-12-23 00:26:30 +01:00
topology: fix potential null pointer from strchr
This patch adds check to the return pointer from strchr, because it may be null and cause segment fault, if component is not properly constructed. Fixes: https://github.com/alsa-project/alsa-utils/pull/91 Signed-off-by: Chao Song <chao.song@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
78212445de
commit
3d7a6facd9
2 changed files with 10 additions and 0 deletions
|
@ -146,6 +146,11 @@ static int tplg_pp_get_widget_name(struct tplg_pre_processor *tplg_pp,
|
||||||
|
|
||||||
/* get class name */
|
/* get class name */
|
||||||
args = strchr(string, '.');
|
args = strchr(string, '.');
|
||||||
|
if (!args) {
|
||||||
|
SNDERR("Error getting class name for %s\n", string);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
class_name = calloc(1, strlen(string) - strlen(args) + 1);
|
class_name = calloc(1, strlen(string) - strlen(args) + 1);
|
||||||
if (!class_name)
|
if (!class_name)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
|
@ -492,6 +492,11 @@ static int tplg_pp_add_object_tuple_section(struct tplg_pre_processor *tplg_pp,
|
||||||
}
|
}
|
||||||
|
|
||||||
type = strchr(token_ref, '.');
|
type = strchr(token_ref, '.');
|
||||||
|
if(!type) {
|
||||||
|
SNDERR("Error getting type for %s\n", token_ref);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
token = calloc(1, strlen(token_ref) - strlen(type) + 1);
|
token = calloc(1, strlen(token_ref) - strlen(type) + 1);
|
||||||
if (!token)
|
if (!token)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
Loading…
Reference in a new issue