Skip to content

Commit 4510fdc

Browse files
committed
---
yaml --- r: 4007 b: refs/heads/master c: 652214d h: refs/heads/master i: 4005: 1cca5d4 4003: a5d9f0a 3999: 63cf1dc v: v3
1 parent fedecae commit 4510fdc

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 19a17b3d1d0d25155c8bd11c73bf88238f9bd180
2+
refs/heads/master: 652214d7f90516fd77394fddd65cda69d8861e58

trunk/src/rt/rust_builtin.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,12 @@ rust_list_files_ivec(rust_task *task, rust_str *path) {
608608
closedir(dirp);
609609
}
610610
#endif
611+
size_t str_ivec_sz =
612+
sizeof(size_t) // fill
613+
+ sizeof(size_t) // alloc
614+
+ sizeof(rust_str *) * 4; // payload
611615
rust_box *box = (rust_box *)task->malloc(sizeof(rust_box) +
612-
sizeof(rust_ivec));
616+
str_ivec_sz);
613617
box->ref_count = 1;
614618
rust_ivec *iv = (rust_ivec *)&box->data;
615619
iv->fill = 0;

trunk/src/rt/rust_util.h

+1
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ rust_ivec_heap
202202
uint8_t data[];
203203
};
204204

205+
// Note that the payload is actually size 4*sizeof(elem), even when heapified
205206
union
206207
rust_ivec_payload
207208
{

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

+9-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,12 @@ fn test_connect() {
99
assert (fs::connect("a" + slash, "b") == "a" + slash + "b");
1010
}
1111

12-
fn main() { test_connect(); }
12+
// Issue #712
13+
fn test_list_dir_no_invalid_memory_access() {
14+
fs::list_dir(".");
15+
}
16+
17+
fn main() {
18+
test_connect();
19+
test_list_dir_no_invalid_memory_access();
20+
}

0 commit comments

Comments
 (0)