summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/string.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/string.cpp b/src/string.cpp
index 2bd747535..b6e40b7b3 100644
--- a/src/string.cpp
+++ b/src/string.cpp
@@ -32,9 +32,9 @@
*/
static int CDECL vseprintf(char *str, const char *last, const char *format, va_list ap)
{
- if (str >= last) return 0;
- size_t size = last - str + 1;
- return min((int)size, vsnprintf(str, size, format, ap));
+ ptrdiff_t diff = last - str;
+ if (diff < 0) return 0;
+ return min((int)diff, vsnprintf(str, diff + 1, format, ap));
}
void ttd_strlcat(char *dst, const char *src, size_t size)