1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-28 01:44:52 +00:00

More array index out of bound protections for viterbi decoder

This commit is contained in:
Javier 2015-06-12 16:10:59 +02:00
parent adf73e0610
commit d9da6e1e60

View File

@ -578,12 +578,22 @@ int Viterbi_Decoder::Prev::get_anchestor_state_of_current_state(int current_stat
int Viterbi_Decoder::Prev::get_bit_of_current_state(int current_state) int Viterbi_Decoder::Prev::get_bit_of_current_state(int current_state)
{ {
//std::cout << "get prev bit : for state " << current_state << " at time " << t << ", the send bit is " << bit[current_state] << std::endl; //std::cout << "get prev bit : for state " << current_state << " at time " << t << ", the send bit is " << bit[current_state] << std::endl;
if (num_states>current_state)
{
return bit[current_state]; return bit[current_state];
}else{
return 0;
}
} }
float Viterbi_Decoder::Prev::get_metric_of_current_state(int current_state) float Viterbi_Decoder::Prev::get_metric_of_current_state(int current_state)
{
if (num_states>current_state)
{ {
return metric[current_state]; return metric[current_state];
}else{
return 0;
}
} }
int Viterbi_Decoder::Prev::get_t() int Viterbi_Decoder::Prev::get_t()
@ -592,16 +602,25 @@ int Viterbi_Decoder::Prev::get_t()
} }
void Viterbi_Decoder::Prev::set_current_state_as_ancestor_of_next_state(int next_state, int current_state) void Viterbi_Decoder::Prev::set_current_state_as_ancestor_of_next_state(int next_state, int current_state)
{
if (num_states>next_state)
{ {
state[next_state] = current_state; state[next_state] = current_state;
} }
}
void Viterbi_Decoder::Prev::set_decoded_bit_for_next_state(int next_state, int bit) void Viterbi_Decoder::Prev::set_decoded_bit_for_next_state(int next_state, int bit)
{
if (num_states>next_state)
{ {
this->bit[next_state] = bit; this->bit[next_state] = bit;
} }
}
void Viterbi_Decoder::Prev::set_survivor_branch_metric_of_next_state(int next_state, float metric) void Viterbi_Decoder::Prev::set_survivor_branch_metric_of_next_state(int next_state, float metric)
{
if (num_states>next_state)
{ {
this->metric[next_state] = metric; this->metric[next_state] = metric;
} }
}