From a67243ec542a1c41fd6cf0baf554b4bd16f86d18 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 8 Jun 2011 23:53:06 +0000 Subject: [PATCH] fix array overrun when jack_get_ports() returns the full set of all possible ports git-svn-id: svn+ssh://jackaudio.org/trunk/jack@4448 0c269be4-1314-0410-8aa9-9f06e86f4224 --- libjack/client.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libjack/client.c b/libjack/client.c index 22c003d..110a484 100644 --- a/libjack/client.c +++ b/libjack/client.c @@ -3022,7 +3022,7 @@ jack_get_ports (jack_client_t *client, psp = engine->ports; match_cnt = 0; - if ((matching_ports = (const char **) malloc (sizeof (char *) * engine->port_max)) == NULL) { + if ((matching_ports = (const char **) malloc (sizeof (char *) * (engine->port_max + 1))) == NULL) { return NULL; } @@ -3065,12 +3065,12 @@ jack_get_ports (jack_client_t *client, regfree (&type_regex); } - matching_ports[match_cnt] = 0; - if (match_cnt == 0) { free (matching_ports); matching_ports = 0; - } + } else { + matching_ports[match_cnt] = 0; + } return matching_ports; }