summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--chat.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/chat.h b/chat.h
index e75112a..327262b 100644
--- a/chat.h
+++ b/chat.h
@@ -52,8 +52,8 @@ static inline char *seprintf(char *ptr, char *end, const char *fmt, ...) {
 	int n = vsnprintf(ptr, end - ptr, fmt, ap);
 	va_end(ap);
 	if (n < 0) return NULL;
-	ptr += n;
-	return (ptr > end ? end : ptr);
+	if (n > end - ptr) return end;
+	return ptr + n;
 }
 
 enum Attr {