Skip to content

Commit 3c0e2d3

Browse files
as-suvorovWovchena
andauthored
Fix coverity for release (#2661)
Port of: #2601 Co-authored-by: Vladimir Zlobin <[email protected]>
1 parent aeb1bd7 commit 3c0e2d3

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/cpp/src/gguf_utils/gguf_tokenizer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,10 @@ std::vector<std::string> split_utf8_chars(const std::string& input) {
299299
std::cerr << "Invalid UTF-8 sequence at byte index " << i << std::endl;
300300
break; // Stop on error
301301
}
302+
OPENVINO_ASSERT(
303+
std::numeric_limits<size_t>::max() - i > len,
304+
"UTF-8 character length exceeds size_t limit at index ", i
305+
);
302306
result.emplace_back(input.substr(i, len));
303307
i += len;
304308
}

src/cpp/src/speculative_decoding/speculative_decoding_impl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ ContinuousBatchingPipeline::SpeculativeDecodingImpl::generate(const std::vector<
348348

349349
SpeculativeDecodingMetrics
350350
ContinuousBatchingPipeline::SpeculativeDecodingImpl::get_speculative_decoding_metrics() {
351+
std::lock_guard<std::mutex> lock{m_draft_generations_mutex};
351352
return m_sd_metrics;
352353
};
353354

src/cpp/src/visual_language/phi3_vision/classes.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,9 @@ std::vector<std::variant<ov::Tensor, size_t>> split_tokenize(const std::string&
483483
{0, 1} // Every match emits two values: whole match and submatch
484484
}; iter != std::sregex_token_iterator{}; ++iter) {
485485
if (is_submatch) {
486-
tokenized.push_back(std::stoul(iter->str()) - 1);
486+
size_t idx = std::stoul(iter->str());
487+
OPENVINO_ASSERT(idx != 0);
488+
tokenized.push_back(idx - 1);
487489
} else {
488490
std::string regular_text{prefix_begin, iter->first};
489491
if (!regular_text.empty()) {

0 commit comments

Comments
 (0)