OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[Coverity] Integer handling issues and null pointer dereferences (#30159)
Pawel Raasze90610e05abc
diff --git a/samples/cpp/benchmark_app/main.cpp b/samples/cpp/benchmark_app/main.cppindex 33db90c6449..112d1a54819 100644--- a/samples/cpp/benchmark_app/main.cpp+++ b/samples/cpp/benchmark_app/main.cpp@@ -258,7 +258,7 @@ void handle_performance_hint(const std::string& device, const ov::Core& core, ovconfig.erase(ov::hint::performance_mode.name());}} else {- if (FLAGS_hint != "none" || FLAGS_hint != "") {+ if (FLAGS_hint != "none" && FLAGS_hint != "") {slog::warn << "Device(" << device << ") does not support performance hint property(-hint)." << slog::endl;}}diff --git a/src/bindings/c/src/ov_tensor.cpp b/src/bindings/c/src/ov_tensor.cppindex eda445e41ce..b86d342aec5 100644--- a/src/bindings/c/src/ov_tensor.cpp+++ b/src/bindings/c/src/ov_tensor.cpp@@ -122,13 +122,16 @@ ov_status_e ov_tensor_get_shape(const ov_tensor_t* tensor, ov_shape_t* shape) {if (!tensor) {return ov_status_e::INVALID_C_PARAM;}+ ov_status_e status = ov_status_e::OK;try {auto tmp_shape = tensor->object->get_shape();- ov_shape_create(tmp_shape.size(), nullptr, shape);- std::copy_n(tmp_shape.begin(), tmp_shape.size(), shape->dims);+ status = ov_shape_create(tmp_shape.size(), nullptr, shape);+ if (status == ov_status_e::OK) {+ std::copy_n(tmp_shape.begin(), tmp_shape.size(), shape->dims);+ }}CATCH_OV_EXCEPTIONS- return ov_status_e::OK;+ return status;}ov_status_e ov_tensor_set_string_data(ov_tensor_t* tensor, const char** string_array, const size_t array_size) {