summaryrefslogtreecommitdiff
path: root/accel-pppd
diff options
context:
space:
mode:
authorGuillaume Nault <g.nault@alphalink.fr>2013-02-14 18:11:53 +0100
committerKozlov Dmitry <xeb@mail.ru>2013-02-17 21:52:58 +0400
commit42b11f05e5c087fcc34579f2e8a807fa8330b6ca (patch)
treec4ae78db4a0d8ca689963fbc19dc7579257ef04d /accel-pppd
parentbfc338f17ebbadf377d59c51895f46f02a926fc8 (diff)
downloadaccel-ppp-42b11f05e5c087fcc34579f2e8a807fa8330b6ca.tar.gz
accel-ppp-42b11f05e5c087fcc34579f2e8a807fa8330b6ca.zip
cli: Fix "show sessions" if no column to display
Gracefully handle the case where no column has been selected for the "show sessions" command. Such situation will be possible once the set of default displayed columns will be made configurable from accel-ppp.conf. Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Diffstat (limited to 'accel-pppd')
-rw-r--r--accel-pppd/cli/show_sessions.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/accel-pppd/cli/show_sessions.c b/accel-pppd/cli/show_sessions.c
index 5bfe09b..33c8f92 100644
--- a/accel-pppd/cli/show_sessions.c
+++ b/accel-pppd/cli/show_sessions.c
@@ -273,11 +273,15 @@ static int show_ses_exec(const char *cmd, char * const *f, int f_cnt, void *cli)
continue;
total_width += col->width + 3;
}
-
+
+ if (total_width < 0)
+ /* No column to print */
+ goto early_out;
+
buf = _malloc(total_width + 3);
if (!buf)
goto oom;
-
+
ptr1 = buf;
list_for_each_entry(col, &c_list, entry) {
if (col->hidden)
@@ -356,6 +360,8 @@ out:
return CLI_CMD_OK;
oom:
+ cli_send(cli, "out of memory");
+early_out:
if (buf)
_free(buf);
@@ -364,7 +370,6 @@ oom:
list_del(&row->entry);
free_row(row);
}
- cli_send(cli, "out of memory");
goto out;
}