diff --git a/win/rl/winrl.cc b/win/rl/winrl.cc index fd5f3d517..32d2d581d 100644 --- a/win/rl/winrl.cc +++ b/win/rl/winrl.cc @@ -8,7 +8,6 @@ #include #include #include -#include #include #include @@ -384,7 +383,8 @@ NetHackRL::fill_obs(nle_obs *obs) int i = 0; for (const rl_inventory_item &item : inventory_) { int j = 0; - for (int size = item.str.size(); j < size; ++j) { + for (int size = min(item.str.size(), NLE_INVENTORY_STR_LENGTH); + j < size; ++j) { obs->inv_strs[i++] = item.str[j]; } for (; j < NLE_INVENTORY_STR_LENGTH; ++j) {