Hum, I must have attached the wrong file, the previous patch doesn't
even compile.  Here is a fixed version.

Samuel
diff -ur sdl-mixer1.2-1.2.6.orig/music_cmd.c sdl-mixer1.2-1.2.6/music_cmd.c
--- sdl-mixer1.2-1.2.6.orig/music_cmd.c 2004-12-16 05:20:14.000000000 +0000
+++ sdl-mixer1.2-1.2.6/music_cmd.c      2007-06-14 19:24:15.000000000 +0000
@@ -55,10 +55,8 @@
                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 = strdup(file);
+       music->cmd = strdup(cmd);
        music->pid = 0;
 
        /* We're done */
@@ -153,15 +151,16 @@
 
            /* Child process - executes here */
            case 0: {
-                   char command[PATH_MAX];
+                   char *command;
                    char **argv;
 
                    /* Execute the command */
-                   strcpy(command, music->cmd);
+                   command = strdup(music->cmd);
                    argv = parse_args(command, music->file);
                    if ( argv != NULL ) {
                        execvp(argv[0], argv);
                    }
+                   free(command);
 
                    /* exec() failed */
                    perror(argv[0]);
@@ -209,6 +208,8 @@
 /* Close the given music stream */
 void MusicCMD_FreeSong(MusicCMD *music)
 {
+       free(music->file);
+       free(music->cmd);
        free(music);
 }

diff -ur sdl-mixer1.2-1.2.6.orig/music_cmd.h sdl-mixer1.2-1.2.6/music_cmd.h
--- sdl-mixer1.2-1.2.6.orig/music_cmd.h 2004-12-16 05:20:14.000000000 +0000
+++ sdl-mixer1.2-1.2.6/music_cmd.h      2007-06-14 19:24:33.000000000 +0000
@@ -33,8 +33,8 @@
 # include <linux/limits.h>
 #endif
 typedef struct {
-       char file[PATH_MAX];
-       char cmd[PATH_MAX];
+       char *file;
+       char *cmd;
        pid_t pid;
 } MusicCMD;
 

Reply via email to