Browse Source

D'oh d'oh d'oh d'oh d'oh d'oh d'oh d'oh d'oh

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
a77b32aaf6
1 changed files with 9 additions and 3 deletions
  1. 9
    3
      src/core/exec.c

+ 9
- 3
src/core/exec.c View File

@@ -119,9 +119,12 @@ static int split_args ( char *args, char * argv[] ) {
119 119
  * Execute the named command and arguments.
120 120
  */
121 121
 int system ( const char *command ) {
122
-	char *args = strdup ( command );
122
+	char *args;
123 123
 	int argc;
124
-	
124
+	int rc;
125
+
126
+	/* Obtain temporary modifiable copy of command line */
127
+	args = strdup ( command );
125 128
 	if ( ! args )
126 129
 		return -ENOMEM;
127 130
 
@@ -134,6 +137,9 @@ int system ( const char *command ) {
134 137
 		
135 138
 		split_args ( args, argv );
136 139
 		argv[argc] = NULL;
137
-		return execv ( argv[0], argv );
140
+		rc = execv ( argv[0], argv );
138 141
 	}
142
+
143
+	free ( args );
144
+	return rc;
139 145
 }

Loading…
Cancel
Save