From 49def3a1559072e29f62e83c2c452da60b18dc5a Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Mon, 27 May 2019 22:52:09 +0100 Subject: [PATCH] wmail: use calloc, instead of malloc + memset. --- wmail/src/wmail.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/wmail/src/wmail.c b/wmail/src/wmail.c index 9f9e400..a8a2b48 100644 --- a/wmail/src/wmail.c +++ b/wmail/src/wmail.c @@ -897,24 +897,20 @@ char *ParseFromField( char *buf ) int maxLen = strlen( buf ) + 1; char *comment; - if(( fullName = malloc( maxLen )) == NULL ) + if(( fullName = calloc( maxLen, sizeof *fullName )) == NULL ) return NULL; - if(( addressName = malloc( maxLen )) == NULL ) + if(( addressName = calloc( maxLen, sizeof *addressName )) == NULL ) { free( fullName ); return NULL; } - if(( comment = malloc( maxLen )) == NULL ) + if(( comment = calloc( maxLen, sizeof *comment )) == NULL ) { free( fullName ); free( addressName ); return NULL; } - memset( fullName, '\0', maxLen ); - memset( addressName, '\0', maxLen ); - memset( comment, '\0', maxLen ); - // FIXME: Don't do that "encoded" dance. It's not intended by // RFC2047, and it's better to just do it in the end. // Cleaner.