summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichaël Meyer <hierophanie@gmail.com>2016-02-04 04:01:19 +0100
committerMichaël Meyer <hierophanie@gmail.com>2016-02-04 04:06:28 +0100
commit1f17487aa952a11f2ac53481b26b5a25b9a2fccc (patch)
treecec3e05eb7b416717edf22fa5f8c301fc8df7c77 /test
parentec0daa50bbedc36a0bada4a0f713eb9dc317d444 (diff)
downloadlibutf8proc-1f17487aa952a11f2ac53481b26b5a25b9a2fccc.tar.gz
libutf8proc-1f17487aa952a11f2ac53481b26b5a25b9a2fccc.tar.bz2
Fix overrun
Diffstat (limited to 'test')
-rw-r--r--test/iterate.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/test/iterate.c b/test/iterate.c
index 30b307d..c1674b7 100644
--- a/test/iterate.c
+++ b/test/iterate.c
@@ -13,11 +13,17 @@ static void testbytes(unsigned char *buf, int len, utf8proc_ssize_t retval, int
utf8proc_int32_t out[16];
utf8proc_ssize_t ret;
+ /* Make a copy to ensure that memory is left uninitialized after "len"
+ * bytes. This way, Valgrind can detect overreads.
+ */
+ unsigned char tmp[16];
+ memcpy(tmp, buf, len);
+
tests++;
- if ((ret = utf8proc_iterate(buf, len, out)) != retval) {
+ if ((ret = utf8proc_iterate(tmp, len, out)) != retval) {
fprintf(stderr, "Failed (%d):", line);
for (int i = 0; i < len ; i++) {
- fprintf(stderr, " 0x%02x", buf[i]);
+ fprintf(stderr, " 0x%02x", tmp[i]);
}
fprintf(stderr, " -> %zd\n", ret);
error++;