else if (l->property_name && l->property_value) {
/* check the property from the property list */
- if (pa_proplist_contains(d->proplist, l->property_name) &&
- strcmp(pa_proplist_gets(d->proplist, l->property_name), l->property_value) == 0)
- return true;
+ if (pa_proplist_contains(d->proplist, l->property_name)) {
+ const char *prop = pa_proplist_gets(d->proplist, l->property_name);
+
+ if (prop && strcmp(prop, l->property_value) == 0) {
+ return true;
+ }
+ }
}
/* no match */
char *p;
int brace_count = 0;
bool braces_present = false;
- char left_buf[len];
- char right_buf[len];
-
-#if 0
- /* check if the rule is still valid */
-
- if (len < 2)
- return NULL;
-
- if (rule[0] != '(' || rule[len-1] != ')')
- return NULL;
-#endif
+ char left_buf[len+1];
+ char right_buf[len+1];
et = pa_xnew0(struct expression_token, 1);
else {
/* this is a literal */
char *begin_lit;
- char buf[strlen(rule)+1];
-
+ char buf[len+1];
struct literal_token *lit = pa_xnew0(struct literal_token, 1);
+
if (!lit) {
delete_expression_token(et);
return NULL;
*l = '\0';
}
else {
- strncpy(buf, rule, sizeof(buf));
+ strncpy(buf, rule, len);
+ buf[len] = '\0';
}
if (strncmp(buf, "NEG", 3) == 0) {
}
lit->var = pa_xstrdup(begin_lit);
+
et->lit = lit;
}
if (et->oper == operator_and) {
if (!gather_conjunction(et->left, c) ||
- !gather_conjunction(et->right, c))
+ !gather_conjunction(et->right, c)) {
return false;
+ }
}
else {
/* literal */
if (!l)
return false;
- gather_literal(et, l);
+ if (!gather_literal(et, l)) {
+ pa_log_error("audio groups config: literal parsing failed");
+ delete_literal(l);
+ return false;
+ }
+ PA_LLIST_INIT(struct literal, l);
PA_LLIST_PREPEND(struct literal, c->literals, l);
}
else {
/* conjunction or literal */
struct conjunction *c = pa_xnew0(struct conjunction, 1);
- if (!gather_conjunction(et, c))
+
+ if (!c)
return false;
+ PA_LLIST_HEAD_INIT(struct literal, c->literals);
+
+ if (!gather_conjunction(et, c)) {
+ delete_conjunction(c);
+ return false;
+ }
+
+ PA_LLIST_INIT(struct conjunction, c);
PA_LLIST_PREPEND(struct conjunction, e->conjunctions, c);
}
if (!e)
goto error;
+ PA_LLIST_HEAD_INIT(struct conjunction, e->conjunctions);
+
/* gather expressions to actual match format */
- gather_expression(e, et);
+ if (!gather_expression(e, et)) {
+ /* gathering the expression from tokens went wrong */
+ pa_log_error("failed to parse audio group stream classification data");
+ goto error;
+ }
-#if 1
+#if 0
print_expression(e);
#endif