chiark / gitweb /
sd-dhcp-lease: fix double realloc
authorTom Gundersen <teg@jklm.no>
Tue, 29 Apr 2014 19:57:11 +0000 (21:57 +0200)
committerTom Gundersen <teg@jklm.no>
Tue, 29 Apr 2014 19:57:59 +0000 (21:57 +0200)
src/libsystemd-network/sd-dhcp-lease.c

index 648e6e2..acdcca8 100644 (file)
@@ -330,12 +330,13 @@ static int deserialize_addresses(struct in_addr **addresses, size_t *size, const
                 new_addresses = realloc(*addresses, (*size + 1) * sizeof(struct in_addr));
                 if (!new_addresses)
                         return -ENOMEM;
+                else
+                        *addresses = new_addresses;
 
                 r = inet_aton(word, &(new_addresses[*size]));
                 if (r < 0)
                         continue;
 
-                *addresses = new_addresses;
                 (*size)++;
         }