fix memory leak in tetra_gsmtap_sendmsg()

gsmtap_sendmsg() may return an error, and we need to free the msg.

Likewise, if we don't even call gsmtap_sendmsg, the msgb must be free'd.

Change-Id: I9b018165982996cafb2fd17e89646177462002c6
Depends: libosmocore I106b09f2a49bf24ce0e8d11fd4d4ee93e9cafdf5
Related: OS#5329
This commit is contained in:
Harald Welte 2021-11-25 14:49:10 +01:00
parent d71027873e
commit b94f26929f
1 changed files with 10 additions and 4 deletions

View File

@ -64,10 +64,16 @@ struct msgb *tetra_gsmtap_makemsg(struct tetra_tdma_time *tm, enum tetra_log_cha
int tetra_gsmtap_sendmsg(struct msgb *msg)
{
if (g_gti)
return gsmtap_sendmsg(g_gti, msg);
else
return 0;
int rc;
if (g_gti) {
rc = gsmtap_sendmsg_free(g_gti, msg);
} else {
msgb_free(msg);
rc = 0;
}
return rc;
}
int tetra_gsmtap_init(const char *host, uint16_t port)