diff options
author | Steven Murdoch <Steven.Murdoch@cl.cam.ac.uk> | 2011-08-31 23:40:29 +0100 |
---|---|---|
committer | Steven Murdoch <Steven.Murdoch@cl.cam.ac.uk> | 2011-08-31 23:40:29 +0100 |
commit | 76fde28475a5b977d1fa94d06c116ec39a386ac8 (patch) | |
tree | 5fd3d86c0cefc36c0d4c983f78a39716baf5026c /src/test | |
parent | 38ee959ea9f7b9a213487e37433a000b7e0df54d (diff) | |
download | tor-76fde28475a5b977d1fa94d06c116ec39a386ac8.tar tor-76fde28475a5b977d1fa94d06c116ec39a386ac8.tar.gz |
Fix off-by-one error when allocating memory in test_util_split_lines()
Triggered "failed OVER picket-fence magic-number check (err 27)" when
memory debugging using dmalloc is enabled (at 'low' or higher).
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_util.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index 3b5d85f37..b903cbfb9 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -1637,7 +1637,8 @@ test_util_split_lines(void *ptr) for (i=0; tests[i].orig_line; i++) { sl = smartlist_create(); - orig_line = tor_malloc(tests[i].orig_length); + /* Allocate space for string and trailing NULL */ + orig_line = tor_malloc(tests[i].orig_length + 1); memcpy(orig_line, tests[i].orig_line, tests[i].orig_length + 1); tor_split_lines(sl, orig_line, tests[i].orig_length); |