From 90b0840d62a123e946e81f514bbe331897da8838 Mon Sep 17 00:00:00 2001
From: Chris Robinson <chris.kcat@gmail.com>
Date: Wed, 3 May 2023 07:44:10 -0700
Subject: Ignore logBufSize if logBuf is null

---
 al/debug.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

(limited to 'al/debug.cpp')

diff --git a/al/debug.cpp b/al/debug.cpp
index f584da99..fa16ff73 100644
--- a/al/debug.cpp
+++ b/al/debug.cpp
@@ -467,16 +467,19 @@ FORCE_ALIGN ALuint AL_APIENTRY alGetDebugMessageLogEXT(ALuint count, ALsizei log
 
         auto &entry = context->mDebugLog.front();
         const size_t tocopy{entry.mMessage.size() + 1};
-        const size_t avail{static_cast<ALuint>(logBufSize - logBufWritten)};
-        if(avail < tocopy)
-            return i;
+        if(logBuf)
+        {
+            const size_t avail{static_cast<ALuint>(logBufSize - logBufWritten)};
+            if(avail < tocopy)
+                return i;
+            std::copy_n(entry.mMessage.data(), tocopy, logBuf+logBufWritten);
+        }
 
         if(sources) sources[i] = GetDebugSourceEnum(entry.mSource);
         if(types) types[i] = GetDebugTypeEnum(entry.mType);
         if(ids) ids[i] = entry.mId;
         if(severities) severities[i] = GetDebugSeverityEnum(entry.mSeverity);
         if(lengths) lengths[i] = static_cast<ALsizei>(tocopy);
-        if(logBuf) std::copy_n(entry.mMessage.data(), tocopy, logBuf+logBufWritten);
 
         logBufWritten += static_cast<ALsizei>(tocopy);
         context->mDebugLog.pop_front();
-- 
cgit v1.2.3