From 4733ddaffaaf81cc7ccd5c099c0afd0a99512d1e Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Fri, 2 Apr 2010 19:06:31 -0700 Subject: [PATCH] Move frame NULL checks into the unstuffing function --- gatchat/gatppp.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c index 6c846025..b5e9d3e5 100644 --- a/gatchat/gatppp.c +++ b/gatchat/gatppp.c @@ -179,9 +179,6 @@ static void ppp_recv(GAtPPP *ppp, struct frame_buffer *frame) guint protocol = ppp_proto(frame->bytes); guint8 *packet = ppp_info(frame->bytes); - if (!frame) - return; - switch (protocol) { case PPP_IP_PROTO: ppp_net_process_packet(ppp->net, packet); @@ -203,8 +200,6 @@ static void ppp_recv(GAtPPP *ppp, struct frame_buffer *frame) lcp_protocol_reject(ppp->lcp, frame->bytes, frame->len); break; }; - - g_free(frame); } /* XXX - Implement PFC and ACFC */ @@ -269,9 +264,11 @@ static void ppp_feed(GAtPPP *ppp, guint8 *data, gsize len) /* store last flag character & decode */ ppp->buffer[ppp->index++] = data[pos]; frame = ppp_decode(ppp, ppp->buffer); - - /* process receive frame */ - ppp_recv(ppp, frame); + if (frame) { + /* process receive frame */ + ppp_recv(ppp, frame); + g_free(frame); + } /* zero buffer */ memset(ppp->buffer, 0, BUFFERSZ);