]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-json: fix off-by-one issue when updating parent for array elements
authorMike Yuan <me@yhndnzj.com>
Thu, 26 Feb 2026 10:07:39 +0000 (11:07 +0100)
committerMike Yuan <me@yhndnzj.com>
Thu, 26 Feb 2026 13:23:12 +0000 (14:23 +0100)
Follow-up for 8525bb369a09f488ec77f94e1557ecc2343eb4ab

src/libsystemd/sd-json/sd-json.c

index 247e9790fee5344d60be8e706e0fb833db540866..647b56555a7bbffba0b8db57ff4e81e8f2466268 100644 (file)
@@ -2235,7 +2235,7 @@ _public_ int sd_json_variant_append_array(sd_json_variant **v, sd_json_variant *
 
                         if (old != *v)
                                 /* Readjust the parent pointers to the new address */
-                                for (size_t i = 1; i < size; i++)
+                                for (size_t i = 0; i < size; i++)
                                         (*v)[1 + i].parent = *v;
 
                         return json_variant_array_put_element(*v, element);