Skip to content

Commit

Permalink
[proto_hep] fix bug introduced in 7190a2d
Browse files Browse the repository at this point in the history
	Commit 7190a2d was freeing the extra chunks twice when
the message was processed as SIP. Now the original hep context
free function is not registered as a context free function, but
called manually each time all the hep processing is done. This
way we avoid the memory leaks that appeared when the message was
not a SIP message, and the chunks were not freed.

(cherry picked from commit 63b2a52)
  • Loading branch information
ionutrazvanionita committed Sep 28, 2016
1 parent 4198511 commit f22b884
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 26 deletions.
23 changes: 0 additions & 23 deletions modules/proto_hep/hep.c
Expand Up @@ -778,26 +778,3 @@ int unpack_hepv3(char *buf, int len, struct hep_desc *h)

return 0;
}

void free_extra_chunks(struct hep_desc* h)
{
generic_chunk_t *it, *foo=NULL;
if (h == NULL)
return;

if (h->version < 3 || h->u.hepv3.chunk_list == NULL)
return;

for (it=h->u.hepv3.chunk_list; it; foo=it, it=it->next) {
if (foo) {
shm_free(foo->data);
shm_free(foo);
}
}

if (foo) {
shm_free(foo->data);
shm_free(foo);
}

}
6 changes: 3 additions & 3 deletions modules/proto_hep/proto_hep.c
Expand Up @@ -192,7 +192,7 @@ static int mod_init(void)
}
}

hep_ctx_idx = context_register_ptr(CONTEXT_GLOBAL, free_hep_context);
hep_ctx_idx = context_register_ptr(CONTEXT_GLOBAL, 0);

return 0;
}
Expand Down Expand Up @@ -941,7 +941,7 @@ static inline int hep_handle_req(struct tcp_req *req,
receive_msg(msg_buf, msg_len, &local_rcv, ctx) <0)
LM_ERR("receive_msg failed \n");

free_extra_chunks(&hep_ctx->h);
free_hep_context(hep_ctx);

if (!size && req != &hep_current_req) {
/* if we no longer need this tcp_req
Expand Down Expand Up @@ -1282,7 +1282,7 @@ static int hep_udp_read_req(struct socket_info *si, int* bytes_read)
receive_msg( msg.s, msg.len, &ri, ctx);
}

free_extra_chunks(&hep_ctx->h);
free_hep_context(hep_ctx);

return 0;

Expand Down

0 comments on commit f22b884

Please sign in to comment.