]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic/fileio: use malloc_usable_size() to use all allocated memory
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 25 Mar 2021 12:50:13 +0000 (13:50 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 26 Mar 2021 14:54:56 +0000 (15:54 +0100)
src/basic/fileio.c

index 7c370d4fc3c413a64d7f9a4b6242eb8aad7cf348..a158ab080d74d4466c183e7eea9ab8a96a268cea 100644 (file)
@@ -426,6 +426,7 @@ int read_full_virtual_file(const char *filename, char **ret_contents, size_t *re
                 buf = malloc(size + 1);
                 if (!buf)
                         return -ENOMEM;
+                size = malloc_usable_size(buf) - 1; /* Use a bigger allocation if we got it anyway */
 
                 for (;;) {
                         ssize_t k;