aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/trace.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-02-24 22:24:11 +0100
committerGitHub Enterprise <[email protected]>2026-02-24 22:24:11 +0100
commitfb19c8a86e89762ea89df3b361494a055680b432 (patch)
tree65f717270e3b52527c9c34aaeab864aec4b214f2 /src/zencore/trace.cpp
parentupdated CLAUDE.md (diff)
downloadzen-fb19c8a86e89762ea89df3b361494a055680b432.tar.xz
zen-fb19c8a86e89762ea89df3b361494a055680b432.zip
Fix zencore bugs and propagate content type through IoBufferBuilder (#783)
- Add missing includes in hashutils.h (`<cstddef>`, `<type_traits>`) - Add `ZenContentType` parameter to all `IoBufferBuilder` factory methods so content type is set at buffer creation time - Fix null dereference in `SharedBuffer::GetFileReference()` when buffer is null - Fix out-of-bounds read in trace command-line argument parsing when arg length exactly matches option length - Add unit tests for 32-bit `CountLeadingZeros`
Diffstat (limited to 'src/zencore/trace.cpp')
-rw-r--r--src/zencore/trace.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/zencore/trace.cpp b/src/zencore/trace.cpp
index 87035554f..a026974c0 100644
--- a/src/zencore/trace.cpp
+++ b/src/zencore/trace.cpp
@@ -165,10 +165,17 @@ GetTraceOptionsFromCommandline(TraceOptions& OutOptions)
auto MatchesArg = [](std::string_view Option, std::string_view Arg) -> std::optional<std::string_view> {
if (Arg.starts_with(Option))
{
- std::string_view::value_type DelimChar = Arg[Option.length()];
- if (DelimChar == ' ' || DelimChar == '=')
+ if (Arg.length() > Option.length())
{
- return Arg.substr(Option.size() + 1);
+ std::string_view::value_type DelimChar = Arg[Option.length()];
+ if (DelimChar == ' ' || DelimChar == '=')
+ {
+ return Arg.substr(Option.size() + 1);
+ }
+ }
+ else
+ {
+ return ""sv;
}
}
return {};