Skip to content

Commit da6bd94

Browse files
authored
[GPU][Coverity] Avoid incrementing end() iterator in LayoutJitter (#30432)
Fix coverity issue with usage of invalid iterator ### Details: - Check for end() iterator before jumping to loop which increments the iterator ### Tickets: - 167165
1 parent ea7c8ac commit da6bd94

File tree

1 file changed

+5
-4
lines changed
  • src/plugins/intel_gpu/src/graph/impls/ocl_v2/utils

1 file changed

+5
-4
lines changed

src/plugins/intel_gpu/src/graph/impls/ocl_v2/utils/jitter.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,12 @@ void LayoutJitter::make_definitions(const layout& l, size_t shape_info_offset) {
115115
m_strides[i] = JitTerm{to_code_string(strides[channel_index])};
116116
} else if (format::is_simple_data_format(fmt)) {
117117
auto channel_it = std::find(actual_channels_order.begin(), actual_channels_order.end(), target_channel);
118+
OPENVINO_ASSERT(channel_it != actual_channels_order.end());
119+
118120
m_strides[i] = JitTerm{"1"};
119-
for (channel_it++; channel_it != actual_channels_order.end(); channel_it++) {
120-
auto idx =
121-
std::distance(default_channels_order.begin(), std::find(default_channels_order.begin(), default_channels_order.end(), *channel_it));
122-
auto idx_ext = channels_map[*channel_it];
121+
for (auto it = std::next(channel_it); it != actual_channels_order.end(); ++it) {
122+
auto idx = std::distance(default_channels_order.begin(), std::find(default_channels_order.begin(), default_channels_order.end(), *it));
123+
auto idx_ext = channels_map[*it];
123124
if (pad._lower_size.at(idx) > 0 || pad._upper_size.at(idx) > 0 || pad._dynamic_dims_mask[idx]) {
124125
m_strides[i] = m_strides[i] * (m_dims[idx_ext] + m_pad_lower[idx_ext] + m_pad_upper[idx_ext]);
125126
} else {

0 commit comments

Comments
 (0)