Skip to content

Commit 2ca653c

Browse files
Don't allow --perform-action if deadbeef is not already running
1 parent c667ecc commit 2ca653c

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

src/main.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -476,27 +476,25 @@ server_exec_command_line (const char *cmdline, int len, char *sendback, int sbsi
476476
puts(output);
477477
}
478478
free (output);
479-
return 0;
479+
return 1;
480480
}
481481
else if (!strncmp (parg, "--perform-action=", strlen ("--perform-action="))) {
482+
if (sendback == NULL) {
483+
puts ("DeaDBeeF must be running in order to perform an action");
484+
return 1;
485+
}
482486
const char *action_name = parg + strlen ("--perform-action=");
483487
DB_plugin_action_t *action = find_action_by_name (action_name);
484488

485489
if (action != NULL && action->callback2 != NULL) {
486490
action->callback2 (action, DDB_ACTION_CTX_MAIN);
487491
deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, DDB_PLAYLIST_CHANGE_CONTENT, 0);
488492
} else {
489-
char response[500];
490-
snprintf (response, sizeof(response), _("Failed to perform action \"%s\"\n"), action_name);
491-
if (sendback) {
492-
snprintf (sendback, sbsize, "%s", response);
493-
} else {
494-
puts (response);
495-
}
493+
snprintf (sendback, sbsize, _("Failed to perform action \"%s\"\n"), action_name);
496494
}
497495

498496
parg += strlen(parg) + 1;
499-
continue;
497+
return 1;
500498
}
501499
else if (!strncmp (parg, "--plugin=", strlen ("--plugin="))) {
502500
if (!strcmp (parg + strlen ("--plugin="), "main")) {

0 commit comments

Comments
 (0)