]> git.sur5r.net Git - i3/i3/blobdiff - src/commands_parser.c
If a title contains a percent sign, make sure it is not swallowed by parsing the...
[i3/i3] / src / commands_parser.c
index 9ae75abea21ff28a1fb53501ece991a2037e46d8..ffe416f04dd1c3659ff0aae5687f02269ee63700 100644 (file)
@@ -148,9 +148,9 @@ static TAILQ_HEAD(criteria_head, criterion) criteria =
  */
 static void push_criterion(void *unused_criteria, const char *type,
                            const char *value) {
-    struct criterion *criterion = malloc(sizeof(struct criterion));
-    criterion->type = strdup(type);
-    criterion->value = strdup(value);
+    struct criterion *criterion = smalloc(sizeof(struct criterion));
+    criterion->type = sstrdup(type);
+    criterion->value = sstrdup(value);
     TAILQ_INSERT_TAIL(&criteria, criterion, criteria);
 }
 
@@ -243,7 +243,7 @@ char *parse_string(const char **walk, bool as_word) {
     if (*walk == beginning)
         return NULL;
 
-    char *str = scalloc(*walk - beginning + 1);
+    char *str = scalloc(*walk - beginning + 1, 1);
     /* We copy manually to handle escaping of characters. */
     int inpos, outpos;
     for (inpos = 0, outpos = 0;
@@ -270,7 +270,7 @@ char *parse_string(const char **walk, bool as_word) {
 CommandResult *parse_command(const char *input, yajl_gen gen) {
     DLOG("COMMAND: *%s*\n", input);
     state = INITIAL;
-    CommandResult *result = scalloc(sizeof(CommandResult));
+    CommandResult *result = scalloc(1, sizeof(CommandResult));
 
     /* A YAJL JSON generator used for formatting replies. */
     command_output.json_gen = gen;