Skip to content

Commit

Permalink
tests: internal: stream_processor: fixed memory leak
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Alminana <[email protected]>
  • Loading branch information
leonardo-albertovich committed Sep 26, 2023
1 parent 36ce4b6 commit 34be60e
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/internal/stream_processor.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,13 @@ static void test_window()
usleep(800000);
}

if (out_buf.buffer != NULL) {
flb_free(out_buf.buffer);

out_buf.buffer = NULL;
out_buf.size = 0;
}

flb_sp_fd_event_test(task->window.fd, task, &out_buf);

flb_info("[sp test] id=%i, SQL => '%s'", check->id, check->exec);
Expand Down Expand Up @@ -560,13 +567,26 @@ static void test_window()

/* Hopping event */
if ((t + 1) % check->window_hop_sec == 0) {
if (out_buf.buffer != NULL) {
flb_free(out_buf.buffer);

out_buf.buffer = NULL;
out_buf.size = 0;
}

flb_sp_fd_event_test(task->window.fd_hop, task, &out_buf);
}

/* Window event */
if ((t + 1) % check->window_size_sec == 0 ||
(t + 1 > check->window_size_sec && (t + 1 - check->window_size_sec) % check->window_hop_sec == 0)) {
flb_free(out_buf.buffer);
if (out_buf.buffer != NULL) {
flb_free(out_buf.buffer);

out_buf.buffer = NULL;
out_buf.size = 0;
}

flb_sp_fd_event_test(task->window.fd, task, &out_buf);
}
flb_free(data_buf.buffer);
Expand Down

0 comments on commit 34be60e

Please sign in to comment.