music_cmd.c
changeset 573 23d69b6621d0
parent 561 87bdb4c81c0b
child 601 05123263dab3
child 892 9dd046cb6cd7
     1.1 --- a/music_cmd.c	Fri Jan 20 19:02:54 2012 -0500
     1.2 +++ b/music_cmd.c	Fri Jan 20 19:07:37 2012 -0500
     1.3 @@ -53,10 +53,8 @@
     1.4  		Mix_SetError("Out of memory");
     1.5  		return(NULL);
     1.6  	}
     1.7 -	strncpy(music->file, file, (sizeof music->file)-1);
     1.8 -	music->file[(sizeof music->file)-1] = '\0';
     1.9 -	strncpy(music->cmd, cmd, (sizeof music->cmd)-1);
    1.10 -	music->cmd[(sizeof music->cmd)-1] = '\0';
    1.11 +	music->file = SDL_strdup(file);
    1.12 +	music->cmd = SDL_strdup(cmd);
    1.13  	music->pid = 0;
    1.14  
    1.15  	/* We're done */
    1.16 @@ -155,7 +153,7 @@
    1.17  
    1.18  	    /* Child process - executes here */
    1.19  	    case 0: {
    1.20 -		    char command[PATH_MAX];
    1.21 +		    char *command;
    1.22  		    char **argv;
    1.23  
    1.24  		    /* Unblock signals in case we're called from a thread */
    1.25 @@ -166,11 +164,12 @@
    1.26  		    }
    1.27  
    1.28  		    /* Execute the command */
    1.29 -		    strcpy(command, music->cmd);
    1.30 +		    command = SDL_strdup(music->cmd);
    1.31  		    argv = parse_args(command, music->file);
    1.32  		    if ( argv != NULL ) {
    1.33  			execvp(argv[0], argv);
    1.34  		    }
    1.35 +		    SDL_free(command);
    1.36  
    1.37  		    /* exec() failed */
    1.38  		    perror(argv[0]);
    1.39 @@ -219,6 +218,8 @@
    1.40  /* Close the given music stream */
    1.41  void MusicCMD_FreeSong(MusicCMD *music)
    1.42  {
    1.43 +	SDL_free(music->file);
    1.44 +	SDL_free(music->cmd);
    1.45  	SDL_free(music);
    1.46  }
    1.47