diff options
| author | Anton <anton@picapica> | 2019-02-26 18:45:17 +0400 |
|---|---|---|
| committer | Anton <anton@picapica> | 2019-02-26 18:45:17 +0400 |
| commit | 567fe3dd1c29882ecc88b2cc7505d2e423afd6f7 (patch) | |
| tree | 4ab7e3fdf75198e7b1ccdf80aedecc9ed87e3223 /PICA_node.c | |
| parent | a1768de90865758da7dbd5bf7710ff5c14db80e6 (diff) | |
| download | pica-pica-567fe3dd1c29882ecc88b2cc7505d2e423afd6f7.tar.gz pica-pica-567fe3dd1c29882ecc88b2cc7505d2e423afd6f7.zip | |
pica-node: fix free of anonssl handle, there was memory leak in timed out newconn-s
Diffstat (limited to 'PICA_node.c')
| -rw-r--r-- | PICA_node.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/PICA_node.c b/PICA_node.c index 097e27e..0a67880 100644 --- a/PICA_node.c +++ b/PICA_node.c @@ -1683,6 +1683,12 @@ void newconn_close(struct newconn* nc) nc->iconn.cl = NULL; + if (nc->anonssl) + { + SSL_free(nc->anonssl); + nc->anonssl = NULL; + } + nc->type = NEWCONN_UNKNOWN; } @@ -1744,6 +1750,7 @@ void newconn_free(struct newconn* nc) { nc->sck = -1; nc->iconn.cl = NULL; + nc->anonssl = NULL; //nc->pos=0; - pos value is being used in processmsgdatastream } @@ -2115,6 +2122,7 @@ struct nodelink *nodelink_list_addnew(struct newconn *nc) nl->sck = nc->sck; nl->addr = nc->addr; nl->anonssl = nc->anonssl; + nc->anonssl = NULL; nl->r_buf = calloc(1, DEFAULT_BUF_SIZE); if (!nl->r_buf) @@ -2536,6 +2544,7 @@ void process_listen_read(fd_set *readfds) if (!SSL_set_fd(nc->anonssl, s)) { SSL_free(nc->anonssl); + nc->anonssl = NULL; return; } @@ -2576,7 +2585,6 @@ void process_newconn_write() if (ret <= 0) { - SSL_free(newconns[i].anonssl); newconn_close(&newconns[i]); break; } @@ -2587,7 +2595,6 @@ void process_newconn_write() { if (!nodelink_list_addnew(&newconns[i])) { - SSL_free(newconns[i].anonssl); newconn_close(&newconns[i]); } @@ -2607,14 +2614,12 @@ void process_newconn_write() if (ret <= 0) { - SSL_free(newconns[i].anonssl); newconn_close(&newconns[i]); break; } SSL_shutdown(newconns[i].anonssl); SHUTDOWN(newconns[i].sck); - SSL_free(newconns[i].anonssl); newconn_close(&newconns[i]); } @@ -2640,7 +2645,6 @@ void process_newconn_read(fd_set *readfds) if (ret <= 0) { - SSL_free(newconns[i].anonssl); newconn_close(&newconns[i]); break; } @@ -2657,7 +2661,6 @@ void process_newconn_read(fd_set *readfds) if (ret <= 0) { - SSL_free(newconns[i].anonssl); newconn_close(&newconns[i]); break; } @@ -2666,7 +2669,6 @@ void process_newconn_read(fd_set *readfds) if(!PICA_processdatastream(newconns[i].buf, &(newconns[i].pos), newconns + i, _msginfo_newconn, MSGINFO_MSGSNUM(_msginfo_newconn) )) { - SSL_free(newconns[i].anonssl); newconn_close(&newconns[i]); } @@ -2714,7 +2716,6 @@ void process_newconn_read(fd_set *readfds) if (ret < 0) { - SSL_free(newconns[i].anonssl); newconn_close(&newconns[i]); break; } |
