@@ -238,7 +238,7 @@ int flb_task_retry_clean(struct flb_task *task, struct flb_output_instance *ins)
238238}
239239
240240/* Allocate an initialize a basic Task structure */
241- static struct flb_task * task_alloc (struct flb_config * config )
241+ struct flb_task * task_alloc (struct flb_config * config )
242242{
243243 int task_id ;
244244 struct flb_task * task ;
@@ -491,22 +491,30 @@ void flb_task_destroy(struct flb_task *task, int del)
491491 }
492492
493493 /* Unlink and release task */
494- mk_list_del (& task -> _head );
494+ if (!mk_list_entry_is_orphan (& task -> _head )) {
495+ mk_list_del (& task -> _head );
496+ }
495497
496498 /* destroy chunk */
497- flb_input_chunk_destroy (task -> ic , del );
499+ if (task -> ic != NULL ) {
500+ flb_input_chunk_destroy (task -> ic , del );
501+ }
498502
499503 /* Remove 'retries' */
500504 mk_list_foreach_safe (head , tmp , & task -> retries ) {
501505 retry = mk_list_entry (head , struct flb_task_retry , _head );
506+
502507 flb_task_retry_destroy (retry );
503508 }
504509
505- flb_input_chunk_set_limits (task -> i_ins );
510+ if (task -> i_ins != NULL ) {
511+ flb_input_chunk_set_limits (task -> i_ins );
512+ }
506513
507- if (task -> event_chunk ) {
514+ if (task -> event_chunk != NULL ) {
508515 flb_event_chunk_destroy (task -> event_chunk );
509516 }
517+
510518 flb_free (task );
511519}
512520
0 commit comments