Skip to content

Commit

Permalink
[Coverity] #1839950 Catch uncaught exception
Browse files Browse the repository at this point in the history
Catch a `std::bad_array_new_length` that can be risen when array
indexing

Signed-off-by: Daekyoung Jung <[email protected]>
  • Loading branch information
Daekyoung Jung authored and jijoongmoon committed Feb 11, 2025
1 parent dc06517 commit e0ec5e1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Applications/ReinforcementLearning/DeepQ/jni/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,14 @@ int main(int argc, char **argv) {
* @brief Generate Lable with next state
*/
for (unsigned int i = 0; i < in_Exp.size(); i++) {
STATE state = in_Exp[i].state;
STATE next_state = in_Exp[i].next_state;
STATE state, next_state;
try {
state = in_Exp[i].state;
next_state = in_Exp[i].next_state;
} catch (std::bad_array_new_length &e) {
std::cerr << "Error during state assignment" << std::endl;
return -1;
}
std::vector<float> in(state.observation.begin(),
state.observation.end());
inbatch.push_back({{in}});
Expand Down

0 comments on commit e0ec5e1

Please sign in to comment.