From feb24d774407326c1e43826b13357916202fe745 Mon Sep 17 00:00:00 2001 From: chen0088 Date: Mon, 12 Aug 2024 14:32:50 +0800 Subject: [PATCH] modify Signed-off-by: chen0088 --- common/src/utils/dcamera_hisysevent_adapter.cpp | 10 ++++++++-- services/channel/src/dcamera_low_latency.cpp | 8 +++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/common/src/utils/dcamera_hisysevent_adapter.cpp b/common/src/utils/dcamera_hisysevent_adapter.cpp index 3a3d2464..27de6310 100644 --- a/common/src/utils/dcamera_hisysevent_adapter.cpp +++ b/common/src/utils/dcamera_hisysevent_adapter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -118,6 +118,13 @@ void ReportCameraOperaterEvent(const std::string& eventName, const std::string& void ReportStartCaptureEvent(const std::string& eventName, EventCaptureInfo& capture, const std::string& errMsg) { + if (capture.encodeType_ < 0 || + capture.encodeType_ >= sizeof(ENUM_ENCODETYPE_STRINGS) / sizeof(ENUM_ENCODETYPE_STRINGS[0]) || + capture.type_ < 0 || + capture.type_ >= sizeof(ENUM_STREAMTYPE_STRINGS) / sizeof(ENUM_STREAMTYPE_STRINGS[0])) { + DHLOGE("Invalid capture parameters."); + return; + } int32_t ret = HiSysEventWrite(HiSysEventNameSpace::Domain::DISTRIBUTED_CAMERA, eventName, HiSysEventNameSpace::EventType::BEHAVIOR, @@ -136,7 +143,6 @@ void ReportStartCaptureEvent(const std::string& eventName, EventCaptureInfo& cap std::string CreateMsg(const char *format, ...) { va_list args; - (void)memset_s(&args, sizeof(va_list), 0, sizeof(va_list)); va_start(args, format); char msg[MSG_MAX_LEN] = {0}; if (vsnprintf_s(msg, sizeof(msg), sizeof(msg) - 1, format, args) < 0) { diff --git a/services/channel/src/dcamera_low_latency.cpp b/services/channel/src/dcamera_low_latency.cpp index 9c80cd85..a528c1a7 100644 --- a/services/channel/src/dcamera_low_latency.cpp +++ b/services/channel/src/dcamera_low_latency.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -95,9 +95,11 @@ int32_t DCameraLowLatency::DisableLowLatency() std::shared_ptr DCameraLowLatency::GetDHFwkKit() { - std::lock_guard lock(dHFwkKitMutex_); if (dHFwkKit_ == nullptr) { - dHFwkKit_ = std::make_shared(); + std::lock_guard lock(dHFwkKitMutex_); + if (dHFwkKit_ == nullptr) { + dHFwkKit_ = std::make_shared(); + } } return dHFwkKit_; } -- Gitee