[monitoring-plugins] Avoid unnecessary malloc and use stack instead

Lorenz Kästle git at monitoring-plugins.org
Mon Jul 10 10:30:13 CEST 2023


 Module: monitoring-plugins
 Branch: master
 Commit: b96a8424f0ec6206238b650c2c63b4bd006ab43a
 Author: Lorenz Kästle <lorenz.kaestle at netways.de>
   Date: Wed Apr 26 09:15:04 2023 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=b96a842

Avoid unnecessary malloc and use stack instead

---

 plugins/check_curl.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 67ae2b0..6294fa0 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -1062,11 +1062,7 @@ GOT_FIRST_CERT:
         bcopy("...",&output_header_search[sizeof(output_header_search)-4],4);
       }
 
-				char *tmp = malloc(DEFAULT_BUFFER_SIZE);
-
-				if (tmp == NULL) {
-					die(STATE_UNKNOWN, "Failed to allocate buffer for output: %s\n", strerror(errno));
-				}
+				char tmp[DEFAULT_BUFFER_SIZE];
 
 				snprintf (tmp,
 					DEFAULT_BUFFER_SIZE,
@@ -1079,7 +1075,6 @@ GOT_FIRST_CERT:
 					server_url);
 
 				strcpy(msg, tmp);
-				free(tmp);
 
 				result = STATE_CRITICAL;
     }



More information about the Commits mailing list