diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index bd4653638a0b38658da5094912bc905f3090e9d2..789b1a7dca11886648e7d1a25daaaa6c915f3757 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -2967,6 +2967,7 @@ static void *_sip_tcp_helper_thread(struct sip_pvt *pvt, struct ast_tcptls_sessi
 					ast_mutex_unlock(&tcptls_session->lock);
 					goto cleanup;
 				}
+				buf[sizeof(buf)-1] = '\0';
 				ast_mutex_unlock(&tcptls_session->lock);
 				if (me->stop)
 					goto cleanup;