Skip to content

Commit

Permalink
better code for freeing sanitizedartist
Browse files Browse the repository at this point in the history
  • Loading branch information
ravachol committed Jul 1, 2024
1 parent 685f758 commit 96e465b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/soundcommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,13 @@ int displaySongNotification(const char *artist, const char *title, const char *c
char *sanitizedArtist = removeBlacklistedChars(artist, blacklist);
char *sanitizedTitle = removeBlacklistedChars(title, blacklist);

if (!sanitizedArtist || !sanitizedTitle)
{
free(sanitizedArtist);
free(sanitizedTitle);
return -1;
}

sanitize_filepath(cover, sanitized_cover, sizeof(sanitized_cover));

char message[MAXPATHLEN + 1024];
Expand All @@ -1177,9 +1184,9 @@ int displaySongNotification(const char *artist, const char *title, const char *c
else if (pid == 0)
{
// Child process
execvp(args[0], args);
// If execvp fails
perror("execvp");
execv(args[0], args);
// If execv fails
perror("execv");
_Exit(EXIT_FAILURE);
}

Expand Down

0 comments on commit 96e465b

Please sign in to comment.