X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Flibcollectdclient%2Fnetwork_buffer.c;h=130da2355a6c0c23713380101edb1fd9d35fc3e4;hb=354f9991530248e45207d236eb74c1cc3d5238ef;hp=61c7c22e2d7ab963a2d98977f8c0c3747ad18723;hpb=ef4a3db895a0aba7107c0f1c6c2ef2a7f128aaf8;p=collectd.git diff --git a/src/libcollectdclient/network_buffer.c b/src/libcollectdclient/network_buffer.c index 61c7c22e..130da235 100644 --- a/src/libcollectdclient/network_buffer.c +++ b/src/libcollectdclient/network_buffer.c @@ -1,6 +1,6 @@ /** * collectd - src/libcollectdclient/network_buffer.c - * Copyright (C) 2010-2012 Florian octo Forster + * Copyright (C) 2010-2015 Florian octo Forster * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -651,19 +651,17 @@ lcc_network_buffer_t *lcc_network_buffer_create (size_t size) /* {{{ */ return (NULL); } - nb = malloc (sizeof (*nb)); + nb = calloc (1, sizeof (*nb)); if (nb == NULL) return (NULL); - memset (nb, 0, sizeof (*nb)); nb->size = size; - nb->buffer = malloc (nb->size); + nb->buffer = calloc (1, nb->size); if (nb->buffer == NULL) { free (nb); return (NULL); } - memset (nb->buffer, 0, nb->size); nb->ptr = nb->buffer; nb->free = nb->size; @@ -792,9 +790,9 @@ int lcc_network_buffer_finalize (lcc_network_buffer_t *nb) /* {{{ */ #if HAVE_LIBGCRYPT if (nb->seclevel == SIGN) - nb_add_signature (nb); + return nb_add_signature (nb); else if (nb->seclevel == ENCRYPT) - nb_add_encryption (nb); + return nb_add_encryption (nb); #endif return (0);