mirror of
https://github.com/curl/curl.git
synced 2026-07-28 09:13:07 +03:00
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
This commit is contained in:
parent
2b126cd708
commit
94400f32e9
13 changed files with 16 additions and 46 deletions
|
|
@ -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. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue