Bluetooth: samples: ipsp: Fix crash on TCP connection closure

Be sure to check for NULL pkt in receive callback, which means TCP
EOF. The fix ported from echo_server sample.

Jira: ZEP-2423

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
This commit is contained in:
Paul Sokolovsky 2017-08-16 17:48:11 +03:00 committed by Jukka Rissanen
parent 480cfac4f2
commit 7ef28df980

View File

@ -270,10 +270,17 @@ static void tcp_received(struct net_context *context,
void *user_data)
{
static char dbg[MAX_DBG_PRINT + 1];
sa_family_t family = net_pkt_family(pkt);
sa_family_t family;
struct net_pkt *reply_pkt;
int ret;
if (!pkt) {
/* EOF condition */
return;
}
family = net_pkt_family(pkt);
snprintf(dbg, MAX_DBG_PRINT, "TCP IPv%c",
family == AF_INET6 ? '6' : '4');