From 682ed433b212b7b0aee682cacb3c2831f3f7260c Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Sun, 18 Mar 2018 13:24:09 +0100 Subject: [PATCH] Possible fix to #167 --- lib/include/srslte/common/pdu.h | 11 ++++++++--- lib/src/common/pdu.cc | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/include/srslte/common/pdu.h b/lib/include/srslte/common/pdu.h index 5d37a0d63..20fe91816 100644 --- a/lib/include/srslte/common/pdu.h +++ b/lib/include/srslte/common/pdu.h @@ -133,11 +133,16 @@ public: // Section 6.1.2 void parse_packet(uint8_t *ptr) { uint8_t *init_ptr = ptr; - nof_subheaders = 0; - while(subheaders[nof_subheaders].read_subheader(&ptr)) { + nof_subheaders = 0; + bool ret = false; + do { + if (nof_subheaders < (int) max_subheaders) { + ret = subheaders[nof_subheaders].read_subheader(&ptr); + } + } while (ret && nof_subheaders < (int) max_subheaders); + if (nof_subheaders + 1 < (int) max_subheaders) { nof_subheaders++; } - nof_subheaders++; for (int i=0;ierror("Trying to write packet with invalid number of subheaders (nof_subheaders=%d).\n", nof_subheaders); log_h->console("Trying to write packet with invalid number of subheaders (nof_subheaders=%d).\n", nof_subheaders); return NULL;