Commit 16d46a7
out_kafka: fix SIGSEGV and memory leak when rd_kafka_new() fails
Move mk_list_init(&ctx->topics) to early initialization to prevent
SIGSEGV crash when rd_kafka_new() fails and flb_out_kafka_destroy()
is called with an uninitialized topics list.
Also fix memory leak of rd_kafka_conf_t by calling rd_kafka_conf_destroy()
on failure path and in flb_out_kafka_destroy() for other error paths.
Set ctx->conf to NULL after successful rd_kafka_new() since ownership
is transferred to the rd_kafka_t handle.
Signed-off-by: jinyong.choi <inimax801@gmail.com>1 parent 07585fe commit 16d46a7
1 file changed
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
239 | 240 | | |
240 | 241 | | |
241 | 242 | | |
| 243 | + | |
| 244 | + | |
242 | 245 | | |
243 | 246 | | |
244 | 247 | | |
| 248 | + | |
| 249 | + | |
245 | 250 | | |
246 | 251 | | |
247 | 252 | | |
| |||
256 | 261 | | |
257 | 262 | | |
258 | 263 | | |
259 | | - | |
260 | 264 | | |
261 | 265 | | |
262 | 266 | | |
| |||
304 | 308 | | |
305 | 309 | | |
306 | 310 | | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
307 | 315 | | |
308 | 316 | | |
309 | 317 | | |
| |||
0 commit comments