Procházet zdrojové kódy

Fixed assert about memory override when logged string is longer than the buffer size

Signed-off-by: pereslav <[email protected]>
pereslav před 4 roky
rodič
revize
f76d09e215
1 změnil soubory, kde provedl 2 přidání a 1 odebrání
  1. 2 1
      Code/Legacy/CrySystem/Log.cpp

+ 2 - 1
Code/Legacy/CrySystem/Log.cpp

@@ -851,7 +851,8 @@ bool CLog::LogToMainThread(const char* szString, ELogType logType, bool bAdd, SL
     {
     {
         // When logging from other thread then main, push all log strings to queue.
         // When logging from other thread then main, push all log strings to queue.
         SLogMsg msg;
         SLogMsg msg;
-        azstrcpy(msg.msg, AZ_ARRAY_SIZE(msg.msg), szString);
+        constexpr size_t maxArraySize = AZ_ARRAY_SIZE(msg.msg);
+        azstrncpy(msg.msg, maxArraySize, szString, maxArraySize - 1);
         msg.bAdd = bAdd;
         msg.bAdd = bAdd;
         msg.destination = destination;
         msg.destination = destination;
         msg.logType = logType;
         msg.logType = logType;