From 2410738dcf00cda49c9f1d5847289f6a48944c2a Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 1 Dec 2013 10:50:19 +0000 Subject: test/chunk-parser-1: fix uninitialized file structures This test failed when during the test on FreeBSD 11.0-CURRENT with MALLOC_DEBUG enabled or if MALLOC_OPTIONS=J is set in the environment. Reported-by: Mikolaj Golub --- test/chunk-parser-1.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/chunk-parser-1.c b/test/chunk-parser-1.c index fd1de49..2e62a13 100644 --- a/test/chunk-parser-1.c +++ b/test/chunk-parser-1.c @@ -19,6 +19,20 @@ static void reset(void) mog_chunk_init(http); } +/* + * we do this because we used tmpfile to generate a temporary file + * and did not use any existing API to open the file. + */ +static void test_mog_file_init(struct mog_file *file) +{ + struct mog_svc *svc = file->svc; + struct mog_ioq *ioq = file->ioq; + + memset(file, 0, sizeof(struct mog_file)); + file->svc = svc; + file->ioq = ioq; +} + static void buf_set(const char *s) { struct mog_file *file; @@ -31,7 +45,7 @@ static void buf_set(const char *s) assert(tmpfd >= 0 && "invalid fd"); http->forward = mog_fd_init(tmpfd, MOG_FD_TYPE_FILE); file = &http->forward->as.file; - file->foff = 0; + test_mog_file_init(file); buf = xstrdup(s); len = strlen(s); } -- cgit v1.2.3-24-ge0c7