Fix calculation of sizeof boxed ivec of str in rt. Closes #712
This commit is contained in:
parent
19a17b3d1d
commit
652214d7f9
3 changed files with 15 additions and 2 deletions
|
|
@ -608,8 +608,12 @@ rust_list_files_ivec(rust_task *task, rust_str *path) {
|
|||
closedir(dirp);
|
||||
}
|
||||
#endif
|
||||
size_t str_ivec_sz =
|
||||
sizeof(size_t) // fill
|
||||
+ sizeof(size_t) // alloc
|
||||
+ sizeof(rust_str *) * 4; // payload
|
||||
rust_box *box = (rust_box *)task->malloc(sizeof(rust_box) +
|
||||
sizeof(rust_ivec));
|
||||
str_ivec_sz);
|
||||
box->ref_count = 1;
|
||||
rust_ivec *iv = (rust_ivec *)&box->data;
|
||||
iv->fill = 0;
|
||||
|
|
|
|||
|
|
@ -202,6 +202,7 @@ rust_ivec_heap
|
|||
uint8_t data[];
|
||||
};
|
||||
|
||||
// Note that the payload is actually size 4*sizeof(elem), even when heapified
|
||||
union
|
||||
rust_ivec_payload
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,4 +9,12 @@ fn test_connect() {
|
|||
assert (fs::connect("a" + slash, "b") == "a" + slash + "b");
|
||||
}
|
||||
|
||||
fn main() { test_connect(); }
|
||||
// Issue #712
|
||||
fn test_list_dir_no_invalid_memory_access() {
|
||||
fs::list_dir(".");
|
||||
}
|
||||
|
||||
fn main() {
|
||||
test_connect();
|
||||
test_list_dir_no_invalid_memory_access();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue