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 --- src/tool_formparse.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/tool_formparse.c') diff --git a/src/tool_formparse.c b/src/tool_formparse.c index 719e3413f..5313b3441 100644 --- a/src/tool_formparse.c +++ b/src/tool_formparse.c @@ -451,11 +451,10 @@ static CURLcode file_or_stdin(curl_mimepart *part, const char *file) if(strcmp(file, "-")) return curl_mime_filedata(part, file); - sip = (standard_input *) malloc(sizeof *sip); + sip = (standard_input *) calloc(1, sizeof *sip); if(!sip) return CURLE_OUT_OF_MEMORY; - memset((char *) sip, 0, sizeof *sip); set_binmode(stdin); /* If stdin is a regular file, do not buffer data but read it when needed. */ -- cgit v1.2.3