diff options
author | Ron Economos <w6rz@comcast.net> | 2016-08-03 21:15:35 -0700 |
---|---|---|
committer | Ron Economos <w6rz@comcast.net> | 2016-08-03 21:15:35 -0700 |
commit | 87846f81b939ab8fa32ffaf4da3cd9a869039a95 (patch) | |
tree | 034e3a2e9469e353679bcada6a33386032771bd1 | |
parent | 25c82caabf1fa96dbe82e8d10f8e7ba6ffc3d5af (diff) |
gr-dtv: Fix segfault in DVB-T interleaver and deinterleaver.
-rw-r--r-- | gnuradio-runtime/include/gnuradio/attributes.h | 8 | ||||
-rw-r--r-- | gr-dtv/lib/dvbt/dvbt_bit_inner_deinterleaver_impl.cc | 10 | ||||
-rw-r--r-- | gr-dtv/lib/dvbt/dvbt_bit_inner_interleaver_impl.cc | 8 |
3 files changed, 14 insertions, 12 deletions
diff --git a/gnuradio-runtime/include/gnuradio/attributes.h b/gnuradio-runtime/include/gnuradio/attributes.h index 0102c110c2..250683f248 100644 --- a/gnuradio-runtime/include/gnuradio/attributes.h +++ b/gnuradio-runtime/include/gnuradio/attributes.h @@ -81,12 +81,10 @@ //////////////////////////////////////////////////////////////////////// // implement cross-compiler VLA macros //////////////////////////////////////////////////////////////////////// -#ifdef C99 -# define __GR_VLA(TYPE, buf, size) TYPE buf[size] -# define __GR_VLA2D(TYPE, buf, size, size2) TYPE buf[size][size2] -#else +#ifdef _MSC_VER # define __GR_VLA(TYPE, buf, size) TYPE * buf = (TYPE *) alloca(sizeof(TYPE) * (size)) -# define __GR_VLA2D(TYPE, buf, size, size2) TYPE ** buf = (TYPE **) alloca(sizeof(TYPE) * (size) * (size2)) +#else +# define __GR_VLA(TYPE, buf, size) TYPE buf[size] #endif #endif /* INCLUDED_GNURADIO_ATTRIBUTES_H */ diff --git a/gr-dtv/lib/dvbt/dvbt_bit_inner_deinterleaver_impl.cc b/gr-dtv/lib/dvbt/dvbt_bit_inner_deinterleaver_impl.cc index 9e45c81018..c10a77c98a 100644 --- a/gr-dtv/lib/dvbt/dvbt_bit_inner_deinterleaver_impl.cc +++ b/gr-dtv/lib/dvbt/dvbt_bit_inner_deinterleaver_impl.cc @@ -26,10 +26,13 @@ #include "dvbt_bit_inner_deinterleaver_impl.h" #include <stdio.h> +#define MAX_MODULATION_ORDER 6 +#define INTERLEAVER_BLOCK_SIZE 126 + namespace gr { namespace dtv { - const int dvbt_bit_inner_deinterleaver_impl::d_bsize = 126; + const int dvbt_bit_inner_deinterleaver_impl::d_bsize = INTERLEAVER_BLOCK_SIZE; int dvbt_bit_inner_deinterleaver_impl::H(int e, int w) @@ -135,9 +138,8 @@ namespace gr { // First index of d_b is Bit interleaver number // Second index of d_b is the position inside Bit interleaver - // Linux: unsigned char d_b[d_v][d_bsize]; - __GR_VLA2D(unsigned char, d_b, d_v, d_bsize); - + unsigned char d_b[MAX_MODULATION_ORDER][INTERLEAVER_BLOCK_SIZE]; + for (int bcount = 0; bcount < bmax; bcount++) { for (int w = 0; w < d_bsize; w++) { int c = in[(bcount * d_bsize) + w]; diff --git a/gr-dtv/lib/dvbt/dvbt_bit_inner_interleaver_impl.cc b/gr-dtv/lib/dvbt/dvbt_bit_inner_interleaver_impl.cc index a5a9847812..43146f02c5 100644 --- a/gr-dtv/lib/dvbt/dvbt_bit_inner_interleaver_impl.cc +++ b/gr-dtv/lib/dvbt/dvbt_bit_inner_interleaver_impl.cc @@ -26,10 +26,13 @@ #include "dvbt_bit_inner_interleaver_impl.h" #include <stdio.h> +#define MAX_MODULATION_ORDER 6 +#define INTERLEAVER_BLOCK_SIZE 126 + namespace gr { namespace dtv { - const int dvbt_bit_inner_interleaver_impl::d_bsize = 126; + const int dvbt_bit_inner_interleaver_impl::d_bsize = INTERLEAVER_BLOCK_SIZE; int dvbt_bit_inner_interleaver_impl::H(int e, int w) @@ -137,8 +140,7 @@ namespace gr { // First index of d_b is Bit interleaver number // Second index of d_b is the position inside the Bit interleaver - // Linux: unsigned char d_b[d_v][d_bsize]; - __GR_VLA2D(unsigned char, d_b, d_v, d_bsize); + unsigned char d_b[MAX_MODULATION_ORDER][INTERLEAVER_BLOCK_SIZE]; for (int bcount = 0; bcount < bmax; bcount++) { for (int i = 0; i < d_bsize; i++) { |