Skip to content

Commit 4266e87

Browse files
committed
---
yaml --- r: 3992 b: refs/heads/master c: fb9a117 h: refs/heads/master v: v3
1 parent 593a42c commit 4266e87

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: a0ab57b3f62017c065c6f3ced67e4c35898b51a3
2+
refs/heads/master: fb9a117743636ac41cf494dde6198c955270a67e

trunk/src/lib/run_program.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ fn arg_vec(str prog, vec[str] args) -> vec[sbuf] {
1414
}
1515

1616
fn run_program(str prog, vec[str] args) -> int {
17-
auto pid =
18-
rustrt::rust_run_program(vec::buf[sbuf](arg_vec(prog, args)), 0, 0,
19-
0);
17+
// Note: we have to hold on to this vector reference while we hold a
18+
// pointer to its buffer
19+
auto argv = arg_vec(prog, args);
20+
auto pid = rustrt::rust_run_program(vec::buf(argv), 0, 0, 0);
2021
ret os::waitpid(pid);
2122
}
2223

@@ -32,8 +33,11 @@ type program =
3233
fn start_program(str prog, vec[str] args) -> @program {
3334
auto pipe_input = os::pipe();
3435
auto pipe_output = os::pipe();
36+
// Note: we have to hold on to this vector reference while we hold a
37+
// pointer to its buffer
38+
auto argv = arg_vec(prog, args);
3539
auto pid =
36-
rustrt::rust_run_program(vec::buf[sbuf](arg_vec(prog, args)),
40+
rustrt::rust_run_program(vec::buf(argv),
3741
pipe_input._0, pipe_output._1, 0);
3842
if (pid == -1) { fail; }
3943
os::libc::close(pipe_input._0);

trunk/src/test/run-pass/lib-run.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// xfail-stage0
2+
3+
use std;
4+
import std::run;
5+
6+
// Regression test for memory leaks
7+
fn test_leaks() {
8+
run::run_program("echo", []);
9+
run::start_program("echo", []);
10+
run::program_output("echo", []);
11+
}
12+
13+
fn main() {
14+
test_leaks();
15+
}

0 commit comments

Comments
 (0)