]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
networkd: Free Prefix in case allocation fails (#7480)
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Mon, 27 Nov 2017 12:07:22 +0000 (14:07 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 27 Nov 2017 12:07:22 +0000 (13:07 +0100)
Set the code to call _cleanup_prefix_free_ in case the next allocation
fails so that Prefix does not leak memory.

Reported by evverx.

src/network/networkd-address.c

index 976be17c0e4ed0f099373dcb87f7077350330067..ff125e35dee1647fdf25919bfca56fdc40699918 100644 (file)
@@ -1035,7 +1035,7 @@ void prefix_free(Prefix *prefix) {
 }
 
 int prefix_new(Prefix **ret) {
-        Prefix *prefix = NULL;
+        _cleanup_prefix_free_ Prefix *prefix = NULL;
 
         prefix = new0(Prefix, 1);
         if (!prefix)