]> git.ipfire.org Git - people/ric9/pakfire.git/commitdiff
strings: setn: Don't copy anything if length is zero
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 6 Jan 2025 21:34:44 +0000 (21:34 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 6 Jan 2025 21:34:44 +0000 (21:34 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/string.c

index 00e8233c78b8e73006cff86338c3e05c81b2429c..728b326db1100b09dad9ce1c5413c2db17e6b2c5 100644 (file)
@@ -76,7 +76,8 @@ int __pakfire_string_setn(char* s, const size_t length, const char* value, const
                return -ENOBUFS;
 
        // Copy the data
-       memcpy(s, value, l);
+       else if (l > 0)
+               memcpy(s, value, l);
 
        // Terminate the result buffer
        s[l] = '\0';