fix: return error strings instead of NULL on popen and realloc failures in tool_function_bash

This commit is contained in:
retoor 2025-03-03 08:48:50 +00:00
parent f8667d1a4b
commit 00c45e0978

View File

@ -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);