From 94400f32e9016d2eaea2db583f6e213c36b1eb1d Mon Sep 17 00:00:00 2001 From: Daniel Gustafsson Date: Sat, 14 Apr 2018 22:42:04 +0200 Subject: all: Refactor malloc+memset to use calloc When a zeroed out allocation is required, use calloc() rather than malloc() followed by an explicit memset(). The result will be the same, but using calloc() everywhere increases consistency in the codebase and avoids the risk of subtle bugs when code is injected between malloc and memset by accident. Closes https://github.com/curl/curl/pull/2497 --- lib/content_encoding.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/content_encoding.c') diff --git a/lib/content_encoding.c b/lib/content_encoding.c index 2b2188b73..7c979efcc 100644 --- a/lib/content_encoding.c +++ b/lib/content_encoding.c @@ -873,10 +873,9 @@ static contenc_writer *new_unencoding_writer(struct connectdata *conn, contenc_writer *downstream) { size_t sz = offsetof(contenc_writer, params) + handler->paramsize; - contenc_writer *writer = (contenc_writer *) malloc(sz); + contenc_writer *writer = (contenc_writer *) calloc(1, sz); if(writer) { - memset(writer, 0, sz); writer->handler = handler; writer->downstream = downstream; if(handler->init_writer(conn, writer)) { -- cgit v1.2.1