From 720313e185e0365a03f8bb648f8daad0e609d343 Mon Sep 17 00:00:00 2001
From: Dominique Martinet <asmadeus@codewreck.org>
Date: Fri, 8 Jun 2018 21:58:40 +0900
Subject: [PATCH] sway/criteria: gcc string truncation warning fix

---
 sway/criteria.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sway/criteria.c b/sway/criteria.c
index a263485a..d9f09ecc 100644
--- a/sway/criteria.c
+++ b/sway/criteria.c
@@ -472,7 +472,9 @@ struct criteria *criteria_parse(char *raw, char **error_arg) {
 			++head;
 		}
 		name = calloc(head - namestart + 1, 1);
-		strncpy(name, namestart, head - namestart);
+		if (head != namestart) {
+			strncpy(name, namestart, head - namestart);
+		}
 		// Parse token value
 		skip_spaces(&head);
 		value = NULL;