]> git.sur5r.net Git - i3/i3/blobdiff - libi3/get_colorpixel.c
docs/hacking-howto: Promote "How to build?" sub-section
[i3/i3] / libi3 / get_colorpixel.c
index 218f82e6f5c25ce1eac70d2c1b5d43f4c427d612..9bdd0a7191e7f151b49fe44df2b7922aeeb0c9dc 100644 (file)
@@ -5,13 +5,13 @@
  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
  *
  */
+#include "libi3.h"
+
 #include <stdlib.h>
 #include <stdint.h>
 #include <string.h>
 
 #include "queue.h"
-#include "libi3.h"
-
 struct Colorpixel {
     char hex[8];
     uint32_t pixel;
@@ -74,7 +74,10 @@ uint32_t get_colorpixel(const char *hex) {
 
     /* Store the result in the cache */
     struct Colorpixel *cache_pixel = scalloc(1, sizeof(struct Colorpixel));
-    strncpy(cache_pixel->hex, hex, 8);
+
+    strncpy(cache_pixel->hex, hex, 7);
+    cache_pixel->hex[7] = '\0';
+
     cache_pixel->pixel = pixel;
 
     SLIST_INSERT_HEAD(&(colorpixels), cache_pixel, colorpixels);