Skip to content

Commit

Permalink
pv: fix memory leak when getting $conid
Browse files Browse the repository at this point in the history
cherry-picked from 0e8ef73
  • Loading branch information
camilleoudot committed Apr 13, 2015
1 parent ac36829 commit a23331f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion modules/pv/pv_core.c
Expand Up @@ -1894,14 +1894,18 @@ int pv_get_tcpconn_id(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
{
struct tcp_connection *con;
int conid;

if (msg == NULL)
return -1;

if ((con = tcpconn_get(msg->rcv.proto_reserved1, 0, 0, 0, 0)) == NULL)
return pv_get_null(msg, param, res);

return pv_get_sintval(msg, param, res, con->id);
conid = con->id;
tcpconn_put(con);

return pv_get_sintval(msg, param, res, conid);
}


Expand Down
2 changes: 2 additions & 0 deletions tcp_main.c
Expand Up @@ -1498,6 +1498,8 @@ struct tcp_connection* _tcpconn_find(int id, struct ip_addr* ip, int port,
/* _tcpconn_find with locks and timeout
* local_addr contains the desired local ip:port. If null any local address
* will be used. IN*ADDR_ANY or 0 port are wild cards.
* If found, the connection's reference counter will be incremented, you might
* want to decrement it after use.
*/
struct tcp_connection* tcpconn_get(int id, struct ip_addr* ip, int port,
union sockaddr_union* local_addr,
Expand Down

0 comments on commit a23331f

Please sign in to comment.