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>
/* get class name */
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);
if (!class_name)
return -ENOMEM;
}
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);
if (!token)
return -ENOMEM;