From 3df6e77996ebfbd83531418f41a3c888910515b5 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 29 Nov 2021 12:46:50 +0100 Subject: [PATCH] jack: handle regcomp errors --- pipewire-jack/src/pipewire-jack.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pipewire-jack/src/pipewire-jack.c b/pipewire-jack/src/pipewire-jack.c index 99d97943e..1fbef3b72 100644 --- a/pipewire-jack/src/pipewire-jack.c +++ b/pipewire-jack/src/pipewire-jack.c @@ -5211,6 +5211,7 @@ const char ** jack_get_ports (jack_client_t *client, struct object *tmp[JACK_PORT_MAX]; const char *str; uint32_t i, count, id; + int r; regex_t port_regex, type_regex; spa_return_val_if_fail(c != NULL, NULL); @@ -5220,10 +5221,18 @@ const char ** jack_get_ports (jack_client_t *client, else id = SPA_ID_INVALID; - if (port_name_pattern && port_name_pattern[0]) - regcomp(&port_regex, port_name_pattern, REG_EXTENDED | REG_NOSUB); - if (type_name_pattern && type_name_pattern[0]) - regcomp(&type_regex, type_name_pattern, REG_EXTENDED | REG_NOSUB); + if (port_name_pattern && port_name_pattern[0]) { + if ((r = regcomp(&port_regex, port_name_pattern, REG_EXTENDED | REG_NOSUB)) != 0) { + pw_log_error("cant compile regex %s: %d", port_name_pattern, r); + return NULL; + } + } + if (type_name_pattern && type_name_pattern[0]) { + if ((r = regcomp(&type_regex, type_name_pattern, REG_EXTENDED | REG_NOSUB)) != 0) { + pw_log_error("cant compile regex %s: %d", type_name_pattern, r); + return NULL; + } + } pw_log_debug("%p: ports id:%d name:\"%s\" type:\"%s\" flags:%08lx", c, id, port_name_pattern, type_name_pattern, flags);