]> 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)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 27 Feb 2026 21:57:05 +0000 (21:57 +0000)
Follow-up for 8525bb369a09f488ec77f94e1557ecc2343eb4ab

(cherry picked from commit 4e6e3b8707c84018051ae1885af20e06b2a5209e)
(cherry picked from commit 372158ab0037733d8fd549fef728446765f3bed5)
(cherry picked from commit 96751656c216fee967be03b03a0671c84191e454)

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

index ce368764b5e4013d21b6e0579d03961aef2dfdb2..91571631ac6b7701f6a73e63fb817ba734c5145e 100644 (file)
@@ -2243,7 +2243,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);