commit b72cf93b074eb03c6d45d0eaaf290568b143a4b0
parent 516c9d2a0b2afa1c10aa66bf45b2f9f09d5ae946
Author: Jacob R. Edwards <n/a>
Date: Fri, 20 May 2022 13:12:20 -0500
Fix empty command bug
When an empty line was received, the input buffer wouldn't increment
causing an infinite loop of perceived empty commands. (This was
caused by the stingy way this programmed when it comes to memory.)
Diffstat:
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/aps/aps.c b/aps/aps.c
@@ -227,8 +227,8 @@ aps_command(struct aps *aps, int s)
if (argv == NULL)
return 1;
if (*argv == NULL) {
- free(argv);
- return respfinish(aps, s, "No command");
+ status = "No command";
+ goto exit;
}
for (com = NULL, i = 0; com == NULL && i < aps->ncoms; ++i)
@@ -239,7 +239,8 @@ aps_command(struct aps *aps, int s)
status = "Command not found";
else
status = com(aps, s, arglen(argv + 1), argv + 1);
-
+
+exit:
len = next - (char *)buf->data;
memmove(buf->data, buf->data + len, buf->len - len);
buf->len -= len;