]> git.sur5r.net Git - i3/i3/blobdiff - i3bar/src/config.c
Use sasprintf() instead of alloc'ing and strncpy() in i3bar.
[i3/i3] / i3bar / src / config.c
index 0e2dd05a88d338400291f931558c7f875a47223c..f3412719b7f9a52b19e46616108f590cd3d1792b 100644 (file)
@@ -30,10 +30,7 @@ static bool parsing_bindings;
  */
 static int config_map_key_cb(void *params_, const unsigned char *keyVal, size_t keyLen) {
     FREE(cur_key);
-
-    cur_key = smalloc(sizeof(unsigned char) * (keyLen + 1));
-    strncpy(cur_key, (const char *)keyVal, keyLen);
-    cur_key[keyLen] = '\0';
+    sasprintf(&(cur_key), "%.*s", keyLen, keyVal);
 
     if (strcmp(cur_key, "bindings") == 0)
         parsing_bindings = true;