From d86ca619cf532a010198dfa0d9f5ed8f29f0d673 Mon Sep 17 00:00:00 2001 From: stderr64 Date: Mon, 4 Mar 2024 19:59:10 +0200 Subject: Make sure memory is allocated for command output and fixes to Makefile --- webhook_exec.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'webhook_exec.h') diff --git a/webhook_exec.h b/webhook_exec.h index 445ed88..48b9a4b 100644 --- a/webhook_exec.h +++ b/webhook_exec.h @@ -23,6 +23,11 @@ char *webhook_exec( webhooks_data_t *wh_data, char *wh_endpoint ){ } wh_data->wh_response = NULL; wh_data->wh_output = (char*)calloc( (size_t)MAX_WEBHOOK_OUTPUT_LENGTH, sizeof(char) ); + if ( wh_data->wh_output == NULL ){ + wh_data->wh_command = NULL; + wh_data->wh_output = NULL; + return "Error: failed to allocate memory for command output"; + } FILE *wh_proc = popen( wh_data->wh_command->valuestring, "r" ); if ( wh_proc == NULL ){ free( wh_data->wh_output ); -- cgit v1.2.3-86-g962b