This fix ensures that the loglevel expression is appended to the filter
expression and does not overwrite the current one.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
}
if (err < 0) {
PERROR("asprintf");
- goto end;
+ goto error;
}
}
op = "==";
}
- if (filter) {
- err = asprintf(&jul_filter, "%s && int_loglevel %s %d", filter, op,
+ if (filter || jul_filter) {
+ char *new_filter;
+
+ err = asprintf(&new_filter, "%s && int_loglevel %s %d",
+ jul_filter ? jul_filter : filter, op,
ev->loglevel);
+ if (jul_filter) {
+ free(jul_filter);
+ }
+ jul_filter = new_filter;
} else {
err = asprintf(&jul_filter, "int_loglevel %s %d", op,
ev->loglevel);
}
if (err < 0) {
PERROR("asprintf");
- free(jul_filter);
- jul_filter = NULL;
- goto end;
+ goto error;
}
}
-end:
return jul_filter;
+error:
+ free(jul_filter);
+ return NULL;
}
/*