diff options
author | Chris Robinson <[email protected]> | 2023-05-01 03:43:25 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-05-01 03:43:25 -0700 |
commit | bd8c13d7883cb0a570f724885c7a55ad687dada6 (patch) | |
tree | 3cafbeece891e9187615ca1dc3b21fb3672ff385 /alc/context.cpp | |
parent | 0e7d078b01e423e7973cc593046f9716d1ca8c0b (diff) |
Fix some debug message length limit checks
Diffstat (limited to 'alc/context.cpp')
-rw-r--r-- | alc/context.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/alc/context.cpp b/alc/context.cpp index d4019bc9..bb4930ee 100644 --- a/alc/context.cpp +++ b/alc/context.cpp @@ -308,19 +308,22 @@ void ALCcontext::sendDebugMessage(DebugSource source, DebugType type, ALuint id, { static_assert(DebugSeverityBase+DebugSeverityCount <= 32, "Too many debug bits"); + /* MaxDebugMessageLength is the size including the null terminator, + * <length> does not include the null terminator. + */ if(length < 0) { size_t newlen{std::strlen(message)}; - if(newlen > MaxDebugMessageLength) UNLIKELY + if(newlen >= MaxDebugMessageLength) UNLIKELY { - ERR("Debug message too long (%zu > %d)\n", newlen, MaxDebugMessageLength); + ERR("Debug message too long (%zu >= %d)\n", newlen, MaxDebugMessageLength); return; } length = static_cast<ALsizei>(newlen); } - else if(length > MaxDebugMessageLength) UNLIKELY + else if(length >= MaxDebugMessageLength) UNLIKELY { - ERR("Debug message too long (%d > %d)\n", length, MaxDebugMessageLength); + ERR("Debug message too long (%d >= %d)\n", length, MaxDebugMessageLength); return; } |