Skip to content

Commit

Permalink
Fixed bug 1386 - Debian patch: GNU Hurd support
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jan 21, 2012
1 parent e0e91d4 commit 8ef9727
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions music_cmd.c
Expand Up @@ -53,10 +53,8 @@ MusicCMD *MusicCMD_LoadSong(const char *cmd, const char *file)
Mix_SetError("Out of memory");
return(NULL);
}
strncpy(music->file, file, (sizeof music->file)-1);
music->file[(sizeof music->file)-1] = '\0';
strncpy(music->cmd, cmd, (sizeof music->cmd)-1);
music->cmd[(sizeof music->cmd)-1] = '\0';
music->file = SDL_strdup(file);
music->cmd = SDL_strdup(cmd);
music->pid = 0;

/* We're done */
Expand Down Expand Up @@ -155,7 +153,7 @@ void MusicCMD_Start(MusicCMD *music)

/* Child process - executes here */
case 0: {
char command[PATH_MAX];
char *command;
char **argv;

/* Unblock signals in case we're called from a thread */
Expand All @@ -166,11 +164,12 @@ void MusicCMD_Start(MusicCMD *music)
}

/* Execute the command */
strcpy(command, music->cmd);
command = SDL_strdup(music->cmd);
argv = parse_args(command, music->file);
if ( argv != NULL ) {
execvp(argv[0], argv);
}
SDL_free(command);

/* exec() failed */
perror(argv[0]);
Expand Down Expand Up @@ -219,6 +218,8 @@ void MusicCMD_Resume(MusicCMD *music)
/* Close the given music stream */
void MusicCMD_FreeSong(MusicCMD *music)
{
SDL_free(music->file);
SDL_free(music->cmd);
SDL_free(music);
}

Expand Down
4 changes: 2 additions & 2 deletions music_cmd.h
Expand Up @@ -30,8 +30,8 @@
# include <linux/limits.h>
#endif
typedef struct {
char file[PATH_MAX];
char cmd[PATH_MAX];
char *file;
char *cmd;
pid_t pid;
} MusicCMD;

Expand Down

0 comments on commit 8ef9727

Please sign in to comment.