]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
strxcpyx: do not access dest as an array
authorMike Yuan <me@yhndnzj.com>
Sat, 25 Oct 2025 17:29:33 +0000 (19:29 +0200)
committerMike Yuan <me@yhndnzj.com>
Sat, 25 Oct 2025 17:31:06 +0000 (19:31 +0200)
dest is a pointer to a string, not an array. Accessing
the "first element" just happens to work, but let's
be more careful.

src/basic/strxcpyx.c

index 9126e1dfe26d51b23e8fae67f18908968b5e0f80..dc40d620e7e6bd9aa10954cba4f35e24ce5f8228 100644 (file)
@@ -41,7 +41,7 @@ size_t strnpcpy_full(char **dest, size_t size, const char *src, size_t len, bool
         if (ret_truncated)
                 *ret_truncated = truncated;
 
-        *dest[0] = '\0';
+        (*dest)[0] = '\0';
         return size;
 }