From 725b55c97307c6f0d46587bbe8899cd5c5ca9979 Mon Sep 17 00:00:00 2001 From: chen0088 Date: Thu, 12 Dec 2024 10:06:35 +0800 Subject: [PATCH] modify Signed-off-by: chen0088 --- common/src/utils/dh_log.cpp | 4 +--- .../cameraoperator/client/src/dcamera_client.cpp | 4 +++- .../dcameradata/dcamera_stream_data_process.cpp | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/common/src/utils/dh_log.cpp b/common/src/utils/dh_log.cpp index 4aa9ffa9..91403c9c 100644 --- a/common/src/utils/dh_log.cpp +++ b/common/src/utils/dh_log.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 @@ -76,8 +76,6 @@ void DHLog(DHLogLevel logLevel, const char *fmt, ...) { char logBuf[LOG_MAX_LEN] = {0}; va_list arg; - - (void)memset_s(&arg, sizeof(va_list), 0, sizeof(va_list)); va_start(arg, fmt); int32_t ret = vsprintf_s(logBuf, sizeof(logBuf), fmt, arg); va_end(arg); diff --git a/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp b/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp index f99a23e7..98662430 100644 --- a/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp +++ b/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp @@ -35,7 +35,9 @@ namespace DistributedHardware { DCameraClient::DCameraClient(const std::string& dhId) { DHLOGI("DCameraClient Constructor dhId: %{public}s", GetAnonyString(dhId).c_str()); - cameraId_ = dhId.substr(CAMERA_ID_PREFIX.size()); + if (dhId.size() >= CAMERA_ID_PREFIX.size()) { + cameraId_ = dhId.substr(CAMERA_ID_PREFIX.size()); + } isInit_ = false; } diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_stream_data_process.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_stream_data_process.cpp index 93daa0f1..5747a9b5 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_stream_data_process.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_stream_data_process.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -186,6 +186,7 @@ int32_t DCameraStreamDataProcess::GetProducerSize() void DCameraStreamDataProcess::FeedStreamToSnapShot(const std::shared_ptr& buffer) { + CHECK_AND_RETURN_LOG(buffer == nullptr, "buffer is nullptr."); uint64_t buffersSize = static_cast(buffer->Size()); DHLOGD("DCameraStreamDataProcess FeedStreamToSnapShot devId %{public}s dhId %{public}s streamType %{public}d " "streamSize: %{public}" PRIu64, GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), @@ -198,6 +199,7 @@ void DCameraStreamDataProcess::FeedStreamToSnapShot(const std::shared_ptr& buffer) { + CHECK_AND_RETURN_LOG(buffer == nullptr, "buffer is nullptr."); uint64_t buffersSize = static_cast(buffer->Size()); DHLOGD("DCameraStreamDataProcess FeedStreamToContinue devId %{public}s dhId %{public}s streamType %{public}d " "streamSize: %{public}" PRIu64, GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), -- Gitee