Skip to content

Commit 60dff8c

Browse files
danlenaredsiper
authored andcommitted
in_systemd: Don't insert rows if flb_sqldb_query fails
This can potentially cause an issue where a new row is inserted into in_systemd_cursor table and in_systemd_cursor table can now have more than one row. Once multiple rows exist in the table, this then causes a memory leak as strdup will be called for each row to set qs.cursor in cb_cursor_check, however qs.cursor will only be freed once. Signed-off-by: Daniel Lenar <[email protected]>
1 parent 92e62dd commit 60dff8c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

plugins/in_systemd/systemd_db.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ int flb_systemd_db_init_cursor(struct flb_systemd_config *ctx, const char *curso
137137
ret = flb_sqldb_query(ctx->db,
138138
SQL_GET_CURSOR, cb_cursor_check, &qs);
139139

140+
if (ret != FLB_OK) {
141+
return -1;
142+
}
143+
140144
if (qs.rows == 0) {
141145
/* Register the cursor */
142146
snprintf(query, sizeof(query) - 1,

0 commit comments

Comments
 (0)