fix functions memory leak (#14419)

* fix functions memory leak

* free the buffer only when we should free the resources
This commit is contained in:
Costa Tsaousis 2023-02-02 20:20:04 +02:00 committed by GitHub
parent 2b4241fe5a
commit 93a7a1222e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -670,13 +670,14 @@ int rrd_call_function_and_wait(RRDHOST *host, BUFFER *wb, int timeout, const cha
netdata_mutex_unlock(&tmp->mutex);
}
else {
buffer_free(temp_wb);
if(!buffer_strlen(wb))
rrd_call_function_error(wb, "Failed to send request to the collector.", code);
}
if (we_should_free)
if (we_should_free) {
rrd_function_call_wait_free(tmp);
buffer_free(temp_wb);
}
}
return code;