1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-27 13:21:11 +03:00

buffer: Use calloc to allocate a zero'ed buffer

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Andreas Schneider
2017-02-06 09:42:49 +01:00
parent de369b46b1
commit 166b9f7709

View File

@@ -84,12 +84,12 @@ static void buffer_verify(ssh_buffer buf){
* @return A newly initialized SSH buffer, NULL on error. * @return A newly initialized SSH buffer, NULL on error.
*/ */
struct ssh_buffer_struct *ssh_buffer_new(void) { struct ssh_buffer_struct *ssh_buffer_new(void) {
struct ssh_buffer_struct *buf = malloc(sizeof(struct ssh_buffer_struct)); struct ssh_buffer_struct *buf =
calloc(1, sizeof(struct ssh_buffer_struct));
if (buf == NULL) { if (buf == NULL) {
return NULL; return NULL;
} }
memset(buf, 0, sizeof(struct ssh_buffer_struct));
buffer_verify(buf); buffer_verify(buf);
return buf; return buf;
} }