BUG/MINOR: sink: fix errors handling in cfg_post_parse_ring()

Multiple error paths (memory,IO related) in cfg_post_parse_ring() were
not implemented correcly and could result in memory leak or undefined
behavior.

Fixing them all at once.

This can be backported in 2.4

(cherry picked from commit 9859e00981fa29d6ab8dfa5bfc479aefb0a1bcf5)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 727e39673dac84783541a9e751fa3bf40a8e3998)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit e8946a613ccbf6e2bd5f8d8c37b55f1e970bd296)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 7fe10487a78799542c7d76df1350e28d0696515e)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/sink.c b/src/sink.c
index 694c568..3a6cae7 100644
--- a/src/sink.c
+++ b/src/sink.c
@@ -1156,11 +1156,16 @@
 				if (!ring_attach(cfg_sink->ctx.ring)) {
 					ha_alert("server '%s' sets too many watchers > 255 on ring '%s'.\n", srv->id, cfg_sink->name);
 					err_code |= ERR_ALERT | ERR_FATAL;
+					ha_free(&sft);
+					break;
 				}
 				cfg_sink->sft = sft;
 				srv = srv->next;
 			}
-			sink_init_forward(cfg_sink);
+			if (sink_init_forward(cfg_sink) == 0) {
+				ha_alert("error when trying to initialize sink buffer forwarding.\n");
+				err_code |= ERR_ALERT | ERR_FATAL;
+			}
 		}
 	}
 	cfg_sink = NULL;