]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Fix multiple evaluation of HASH_ADD_STR argument
authorAlberto Leiva Popper <ydahhrk@gmail.com>
Mon, 26 Jun 2023 18:16:24 +0000 (12:16 -0600)
committerAlberto Leiva Popper <ydahhrk@gmail.com>
Mon, 26 Jun 2023 18:19:17 +0000 (12:19 -0600)
This bug was introduced by 330240b2b5de670858a492703f016da21cc374bd.

src/visited_uris.c

index e935e6e2e0adba48b1f7514973e1c9d3fc6e213b..5539ca249e6a2cb8588a6122ed13d1c42b74afb3 100644 (file)
@@ -91,8 +91,13 @@ elem_find(struct visited_uris *list, char const *uri)
 void
 visited_uris_add(struct visited_uris *uris, char const *uri)
 {
-       if (elem_find(uris, uri) == NULL)
-               HASH_ADD_STR(uris->table, uri, visited_elem_create(uri));
+       struct visited_elem *node;
+
+       if (elem_find(uris, uri) == NULL) {
+               /* Do not inline; HASH_ADD_STR expands "add" multiple times. */
+               node = visited_elem_create(uri);
+               HASH_ADD_STR(uris->table, uri, node);
+       }
 }
 
 int