summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--accel-pppd/cli/telnet.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/accel-pppd/cli/telnet.c b/accel-pppd/cli/telnet.c
index 33a82e47..4b5f63ba 100644
--- a/accel-pppd/cli/telnet.c
+++ b/accel-pppd/cli/telnet.c
@@ -732,11 +732,14 @@ static void load_history_file(void)
return;
while (fgets((char *)temp_buf, RECV_BUF_SIZE, f)) {
- b = _malloc(sizeof(*b) + strlen((char *)temp_buf) + 1);
- b->p_buf = NULL;
- b->size = strlen((char *)temp_buf) - 1;
- memcpy(b->buf, temp_buf, b->size);
- list_add_tail(&b->entry, &history);
+ int buf_len=strlen((char *)temp_buf);
+ if( buf_len > 0){
+ b = _malloc(sizeof(*b) + buf_len + 1);
+ b->p_buf = NULL;
+ b->size = buf_len - 1;
+ memcpy(b->buf, temp_buf, b->size);
+ list_add_tail(&b->entry, &history);
+ }
}
fclose(f);