[monitoring-plugins] Use memory on stack instead of heap for temporary ...

RincewindsHat git at monitoring-plugins.org
Thu Sep 21 12:10:12 CEST 2023


 Module: monitoring-plugins
 Branch: master
 Commit: c5e90822d7db1db504e19007a7078d1fa09267f2
 Author: RincewindsHat <12514511+RincewindsHat at users.noreply.github.com>
   Date: Sun Jul 23 22:07:33 2023 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=c5e9082

Use memory on stack instead of heap for temporary variables

---

 lib/utils_base.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/lib/utils_base.c b/lib/utils_base.c
index 176fa85..0f52126 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -407,11 +407,7 @@ char *_np_state_generate_key() {
 	char keyname[41];
 	char *p=NULL;
 
-	unsigned char *result = malloc(256 * sizeof(unsigned char));
-
-	if (result == NULL) {
-		die(STATE_UNKNOWN, _("Failed to allocate memory for hashes: %s"), strerror(errno));
-	}
+	unsigned char result[256];
 
 #ifdef USE_OPENSSL
 	/*



More information about the Commits mailing list