]> git.ipfire.org Git - people/ric9/pakfire.git/commitdiff
strings: Don't clear the entire buffer when resetting a string
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 6 Jan 2025 21:35:03 +0000 (21:35 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 6 Jan 2025 21:35:03 +0000 (21:35 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/string.c

index 728b326db1100b09dad9ce1c5413c2db17e6b2c5..74992a9acd9fc69fdeb7b4335f0963fa7757815d 100644 (file)
@@ -60,8 +60,7 @@ int __pakfire_string_vformat(char* s, const size_t length, const char* format, v
 int __pakfire_string_set(char* s, const size_t length, const char* value) {
        // If value is NULL or an empty, we will overwrite the buffer with just zeros
        if (!value || !*value) {
-               for (unsigned int i = 0; i < length; i++)
-                       s[i] = '\0';
+               *s = '\0';
 
                return 0;
        }