Skip to content

Commit ce0eff8

Browse files
committed
acap/jack: print help early
fixes a leak with CID 472122 also avoid using alloca
1 parent e8ae7eb commit ce0eff8

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/audio/capture/jack.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,15 @@ static void * audio_cap_jack_init(struct module *parent, const char *cfg)
145145
jack_status_t status;
146146
const char **ports;
147147
int i;
148-
char *client_name;
148+
char client_name[STR_LEN];
149149
const char *source_name = NULL;
150150

151-
client_name = alloca(MAX(strlen(PACKAGE_NAME), strlen(cfg)) + 1);
152-
strcpy(client_name, PACKAGE_NAME);
151+
snprintf_ch(client_name, "%s", PACKAGE_NAME);
152+
153+
if (strcmp(cfg, "help") == 0) {
154+
audio_cap_jack_help(client_name);
155+
return INIT_NOERR;
156+
}
153157

154158
struct state_jack_capture *s = (struct state_jack_capture *) calloc(1, sizeof(struct state_jack_capture));
155159
if(!s) {
@@ -167,12 +171,7 @@ static void * audio_cap_jack_init(struct module *parent, const char *cfg)
167171
assert(dup != NULL);
168172
char *tmp = dup, *item, *save_ptr;
169173
while ((item = strtok_r(tmp, ":", &save_ptr)) != NULL) {
170-
if (strcmp(item, "help") == 0) {
171-
audio_cap_jack_help(client_name);
172-
free(dup);
173-
free(s);
174-
return INIT_NOERR;
175-
} else if (strstr(item, "first_channel=") == item) {
174+
if (strstr(item, "first_channel=") == item) {
176175
char *endptr;
177176
char *val = item + strlen("first_channel=");
178177
errno = 0;

0 commit comments

Comments
 (0)