From 7bf9f49728a306976b1974a52a9039807b0a2979 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Thu, 11 Jun 2015 12:45:47 +0200 Subject: [PATCH] tbf: Check for NULL in name() (Coverity) The gprs_rlcmac_tbf::name() method is generally used to generate log messages. To avoid the need for an explicit NULL check for the tbf and to get a consistent text if it is NULL, this commit adds a NULL check to the method itself so that it can be called with this == NULL. Fixes: Coverity CID 1304680, 1304681 Sponsored-by: On-Waves ehf --- src/tbf.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tbf.cpp b/src/tbf.cpp index f3c5e69e..ac099cf0 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -914,6 +914,9 @@ const char *tbf_name(gprs_rlcmac_tbf *tbf) const char *gprs_rlcmac_tbf::name() const { + if (this == NULL) + return "(no TBF)"; + snprintf(m_name_buf, sizeof(m_name_buf) - 1, "TBF(TFI=%d TLLI=0x%08x DIR=%s STATE=%s)", m_tfi, tlli(),