about summary refs log tree commit diff
path: root/src/rt
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-02-10 11:26:50 -0800
committerBrian Anderson <banderson@mozilla.com>2012-02-10 12:58:35 -0800
commitdd0ae80e63beed52164eac76bc94b36b73b6c590 (patch)
tree8a5377ddaa5a50dcd0e9891b4c705c46d24a7061 /src/rt
parentfc028c30a0570e097f4f16f9731c1433226e5367 (diff)
downloadrust-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.h8
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);