diff options
| author | Ray <[email protected]> | 2023-10-11 12:20:03 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2023-10-11 12:20:03 +0200 |
| commit | 61af8e76310cfc23015e0eaee99c55fb72714a30 (patch) | |
| tree | 3c43a4543c7d5366166a1efa0f4f178fafabd9d8 /src/rtext.c | |
| parent | 28fb58f0ea11f0b30b8aaf79d7bb148491ed8775 (diff) | |
| download | raylib-61af8e76310cfc23015e0eaee99c55fb72714a30.tar.gz raylib-61af8e76310cfc23015e0eaee99c55fb72714a30.zip | |
REVIEWED: #3399, Fix #3366
Diffstat (limited to 'src/rtext.c')
| -rw-r--r-- | src/rtext.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/rtext.c b/src/rtext.c index 16b65507..593fdb53 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -1371,14 +1371,14 @@ const char *TextFormat(const char *text, ...) va_list args; va_start(args, text); - int charCountRequired = vsnprintf(currentBuffer, MAX_TEXT_BUFFER_LENGTH, text, args); + int requiredByteCount = vsnprintf(currentBuffer, MAX_TEXT_BUFFER_LENGTH, text, args); va_end(args); - // If charCountRequired is larger than the MAX_TEXT_BUFFER_LENGTH, then overflow occured - if(charCountRequired > MAX_TEXT_BUFFER_LENGTH) + // If requiredByteCount is larger than the MAX_TEXT_BUFFER_LENGTH, then overflow occured + if (requiredByteCount >= MAX_TEXT_BUFFER_LENGTH) { // We are going to insert [TRUN] at the end of the string so the user knows what happened - char *truncBuffer = buffers[index] + MAX_TEXT_BUFFER_LENGTH - 7; // 7 = six letters + '\0' + char *truncBuffer = buffers[index] + MAX_TEXT_BUFFER_LENGTH - 7; // Adding 7 bytes = six chars + '\0' sprintf(truncBuffer, "[TRUN]"); } |
