networkd: Free Prefix in case allocation fails (#7480)

Set the code to call _cleanup_prefix_free_ in case the next allocation
fails so that Prefix does not leak memory.

Reported by evverx.
This commit is contained in:
Patrik Flykt
2017-11-27 14:07:22 +02:00
committed by Lennart Poettering
parent 401e33ed56
commit a86d329f22

View 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)