]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
client: do not allow memory allocations to fail
authorVincent Bernat <vincent@bernat.ch>
Sun, 21 Mar 2021 10:21:24 +0000 (11:21 +0100)
committerVincent Bernat <vincent@bernat.ch>
Sun, 21 Mar 2021 10:21:24 +0000 (11:21 +0100)
This leads to some memory leak (quite improbable), but we don't want
to continue running with an incomplete set of commands.

src/client/commands.c

index 291a63b6ce753f450568fe3b5e1f2dcd6892bb19..7e35ecb15c6e6be742b1e433596ba923109d571d 100644 (file)
@@ -167,10 +167,8 @@ commands_new(struct cmd_node *root,
     void *arg)
 {
        struct cmd_node *new = calloc(1, sizeof(struct cmd_node));
-       if (new == NULL) {
-               log_warn("lldpctl", "unable to allocate memory for new command node");
-               return NULL;
-       }
+       if (new == NULL)
+               fatalx("lldpctl", "out of memory");
        new->token = token;
        new->doc = doc;
        new->validate = validate;