about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2019-02-03 18:03:13 +0100
committerLeah Neukirchen <leah@vuxu.org>2019-02-03 18:03:13 +0100
commitadb58509833752e7cc5454f38435b244f2dfb104 (patch)
treea932c78bab6962d5ffb68d3797d9556b39944765
parent6645e80324bd259a2d3b3b372f472bfa05fd51a6 (diff)
downloadmblaze-adb58509833752e7cc5454f38435b244f2dfb104.tar.gz
mblaze-adb58509833752e7cc5454f38435b244f2dfb104.tar.xz
mblaze-adb58509833752e7cc5454f38435b244f2dfb104.zip
blaze822: safe_append: avoid different signedness in comparison
-rw-r--r--blaze822.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/blaze822.c b/blaze822.c
index 188182d..afde3c1 100644
--- a/blaze822.c
+++ b/blaze822.c
@@ -152,14 +152,17 @@ skip_comment(char *s)
 // never writes more than dstmax to dst
 // returns how many bytes were appended
 static size_t
-safe_append(char *dst, size_t dstmax, char *strbeg, char *strend)
+safe_append(char *dst, size_t dstmax, char *srcbeg, char *srcend)
 {
+	size_t srclen = srcend - srcbeg;
 	size_t dstlen = strlen(dst);
-	if (dstmax - dstlen - 1 < strend - strbeg)
-		strend = strbeg + (dstmax - dstlen - 1);
-	memcpy(dst + dstlen, strbeg, strend - strbeg);
-	dst[dstlen + (strend - strbeg)] = 0;
-	return strend - strbeg;
+
+	if (dstmax - dstlen - 1 < srclen)
+		srclen = dstmax - dstlen - 1;
+	memcpy(dst + dstlen, srcbeg, srclen);
+	dst[dstlen + srclen] = 0;
+
+	return srclen;
 }
 
 static size_t