]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Use realloc instead of free/malloc.
authorRoy Marples <roy@marples.name>
Mon, 21 Jul 2014 19:08:22 +0000 (19:08 +0000)
committerRoy Marples <roy@marples.name>
Mon, 21 Jul 2014 19:08:22 +0000 (19:08 +0000)
if-options.c

index 6fa4b12b2eee8cc1e60a5fed6e8b19741918532a..4e921ba812ef98ba56deefe285998e9e6bab6402 100644 (file)
@@ -2062,11 +2062,11 @@ read_config(struct dhcpcd_ctx *ctx,
                for (e = dhcpcd_embedded_conf; *e; e++) {
                        ol = strlen(*e) + 1;
                        if (ol > buflen) {
-                               free(buf);
                                buflen = ol;
-                               buf = malloc(buflen);
+                               buf = realloc(buf, buflen);
                                if (buf == NULL) {
                                        syslog(LOG_ERR, "%s: %m", __func__);
+                                       free(buf);
                                        return NULL;
                                }
                        }