From 00c45e09787e0423f37e23dfc63fcd8fb280a520 Mon Sep 17 00:00:00 2001 From: retoor Date: Mon, 3 Mar 2025 08:48:50 +0000 Subject: [PATCH] fix: return error strings instead of NULL on popen and realloc failures in tool_function_bash --- tools.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools.h b/tools.h index 8c55849..14b4c58 100644 --- a/tools.h +++ b/tools.h @@ -41,7 +41,7 @@ char * tool_function_bash(char * command){ fp = popen(command, "r"); if (fp == NULL) { perror("popen failed"); - return NULL; + return "Popen failed!"; } // Read output in chunks @@ -52,7 +52,7 @@ char * tool_function_bash(char * command){ perror("realloc failed"); free(output); pclose(fp); - return NULL; + return "Failed to allocate memory!"; } output = new_output; strcpy(output + total_size, buffer);