This is an automated email from the ASF dual-hosted git repository.
dmeden pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 24c59aff23 cppcheck - Fix some some errors and warnings. (#12086)
24c59aff23 is described below
commit 24c59aff23aaf4f0eff718e142216e83c113b124
Author: Damian Meden <[email protected]>
AuthorDate: Fri Mar 7 10:37:08 2025 +0100
cppcheck - Fix some some errors and warnings. (#12086)
Make sure we do not fall into UB when checking for string.back.
Initialize char* to nullptr, cppcheck was complaining about this not
being initialized depending on the branch taken.
---
example/plugins/c-api/client_context_dump/client_context_dump.cc | 2 +-
plugins/compress/misc.cc | 2 +-
plugins/experimental/cert_reporting_tool/cert_reporting_tool.cc | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/example/plugins/c-api/client_context_dump/client_context_dump.cc
b/example/plugins/c-api/client_context_dump/client_context_dump.cc
index 74cd375f07..d416c72884 100644
--- a/example/plugins/c-api/client_context_dump/client_context_dump.cc
+++ b/example/plugins/c-api/client_context_dump/client_context_dump.cc
@@ -110,7 +110,7 @@ dump_context(const char *ca_path, const char *ck_path)
san_s.push_back(',');
}
}
- if (san_s.back() == ',') {
+ if (!san_s.empty() && san_s.back() == ',') {
san_s.pop_back();
}
}
diff --git a/plugins/compress/misc.cc b/plugins/compress/misc.cc
index c0086b8c7b..a1b33b79cc 100644
--- a/plugins/compress/misc.cc
+++ b/plugins/compress/misc.cc
@@ -161,7 +161,7 @@ restore_accept_encoding(TSHttpTxn /* txnp ATS_UNUSED */,
TSMBuffer reqp, TSMLoc
const char *
init_hidden_header_name()
{
- char *hidden_header_name;
+ char *hidden_header_name{nullptr};
const char *var_name = "proxy.config.proxy_name";
TSMgmtString result;
diff --git a/plugins/experimental/cert_reporting_tool/cert_reporting_tool.cc
b/plugins/experimental/cert_reporting_tool/cert_reporting_tool.cc
index 4a76a5d1d1..fd1d49f148 100644
--- a/plugins/experimental/cert_reporting_tool/cert_reporting_tool.cc
+++ b/plugins/experimental/cert_reporting_tool/cert_reporting_tool.cc
@@ -109,7 +109,7 @@ dump_context(const char *ca_path, const char *ck_path)
san_s.push_back(',');
}
}
- if (san_s.back() == ',') {
+ if (!san_s.empty() && san_s.back() == ',') {
san_s.pop_back();
}
}