fix functions memory leak (#14419)
* fix functions memory leak * free the buffer only when we should free the resources
Costa Tsaousis committed
Feb 2, 2023 at 20:20 UTC
93a7a1222ed12fed17095dadc5069952d7ab8df8
1 file changed
+3
-2
database/rrdfunctions.c
+3
-2
@@ -670,13 +670,14 @@ int rrd_call_function_and_wait(RRDHOST *host, BUFFER *wb, int timeout, const cha
670
netdata_mutex_unlock(&tmp->mutex);
671
}
672
else {
673
- buffer_free(temp_wb);
673
if(!buffer_strlen(wb))
674
rrd_call_function_error(wb, "Failed to send request to the collector.", code);
675
}
676
678
- if (we_should_free)
677
+ if (we_should_free) {
678
rrd_function_call_wait_free(tmp);
679
+ buffer_free(temp_wb);
680
+ }
681
}
682
683
return code;