diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-02-10 11:26:50 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-02-10 12:58:35 -0800 |
| commit | dd0ae80e63beed52164eac76bc94b36b73b6c590 (patch) | |
| tree | 8a5377ddaa5a50dcd0e9891b4c705c46d24a7061 /src/rt | |
| parent | fc028c30a0570e097f4f16f9731c1433226e5367 (diff) | |
| download | rust-dd0ae80e63beed52164eac76bc94b36b73b6c590.tar.gz rust-dd0ae80e63beed52164eac76bc94b36b73b6c590.zip | |
rt: Account for the size of stack_canary in create_stack
Diffstat (limited to 'src/rt')
| -rw-r--r-- | src/rt/rust_stack.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/rt/rust_stack.h b/src/rt/rust_stack.h index 6d5fea0c7ef..190cfba8c13 100644 --- a/src/rt/rust_stack.h +++ b/src/rt/rust_stack.h @@ -13,13 +13,19 @@ struct stk_seg { uint8_t data[]; }; +// A value that goes at the end of the stack and must not be touched +const uint8_t stack_canary[] = {0xAB, 0xCD, 0xAB, 0xCD, + 0xAB, 0xCD, 0xAB, 0xCD, + 0xAB, 0xCD, 0xAB, 0xCD, + 0xAB, 0xCD, 0xAB, 0xCD}; + void add_stack_canary(stk_seg *stk); template <class T> stk_seg * create_stack(T allocer, size_t sz) { - size_t total_sz = sizeof(stk_seg) + sz; + size_t total_sz = sizeof(stk_seg) + sz + sizeof(stack_canary); stk_seg *stk = (stk_seg *)allocer->malloc(total_sz, "stack"); memset(stk, 0, sizeof(stk_seg)); add_stack_canary(stk); |
