From 9b68d276d8ed1e75aba8a32e93a14a331e5b0907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=9D=99?= Date: Wed, 25 Jun 2025 19:58:29 +0800 Subject: [PATCH] =?UTF-8?q?cj=E7=9B=AE=E5=BD=95=E4=BB=A3=E7=A0=81=E5=9B=9E?= =?UTF-8?q?=E9=80=80=E5=92=8C=E6=97=A0=E6=95=88=E7=BD=AE=E7=A9=BA=E5=9B=9E?= =?UTF-8?q?=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王静 --- common/src/hcf_parcel.c | 1 - frameworks/cj/src/asy_key_generator_impl.cpp | 1 - frameworks/cj/src/cipher_impl.cpp | 1 - frameworks/cj/src/crypto_ffi.cpp | 2 -- frameworks/cj/src/mac_impl.cpp | 1 - frameworks/cj/src/md_impl.cpp | 1 - frameworks/cj/src/random_impl.cpp | 1 - frameworks/cj/src/sign_impl.cpp | 1 - frameworks/cj/src/sym_key_generator_impl.cpp | 1 - frameworks/cj/src/verify_impl.cpp | 1 - frameworks/js/napi/crypto/src/napi_pri_key.cpp | 1 - frameworks/native/src/asym_key.c | 2 -- frameworks/native/src/crypto_asym_cipher.c | 4 ---- plugin/mbedtls_plugin/rand/src/mbedtls_rand.c | 2 +- 14 files changed, 1 insertion(+), 19 deletions(-) diff --git a/common/src/hcf_parcel.c b/common/src/hcf_parcel.c index fa8b56e..739868c 100644 --- a/common/src/hcf_parcel.c +++ b/common/src/hcf_parcel.c @@ -87,7 +87,6 @@ static bool ParcelRealloc(HcParcel *parcel, uint32_t size) return false; } HcfFree(parcel->data); - parcel->data = NULL; parcel->data = newData; parcel->length = size; return true; diff --git a/frameworks/cj/src/asy_key_generator_impl.cpp b/frameworks/cj/src/asy_key_generator_impl.cpp index c34fbc3..2e66639 100644 --- a/frameworks/cj/src/asy_key_generator_impl.cpp +++ b/frameworks/cj/src/asy_key_generator_impl.cpp @@ -24,7 +24,6 @@ AsyKeyGeneratorImpl::AsyKeyGeneratorImpl(HcfAsyKeyGenerator *generator) AsyKeyGeneratorImpl::~AsyKeyGeneratorImpl() { HcfObjDestroy(this->generator_); - this->generator_ = nullptr; } HcfAsyKeyGenerator *AsyKeyGeneratorImpl::GetAsyKeyGenerator() diff --git a/frameworks/cj/src/cipher_impl.cpp b/frameworks/cj/src/cipher_impl.cpp index e240b53..44fc470 100644 --- a/frameworks/cj/src/cipher_impl.cpp +++ b/frameworks/cj/src/cipher_impl.cpp @@ -25,7 +25,6 @@ namespace OHOS { CipherImpl::~CipherImpl() { HcfObjDestroy(this->cipher_); - this->cipher_ = nullptr; } HcfResult CipherImpl::CipherInit(HcfCryptoMode opMode, HcfKey *key, HcfParamsSpec *params) diff --git a/frameworks/cj/src/crypto_ffi.cpp b/frameworks/cj/src/crypto_ffi.cpp index fd803f2..75e038f 100644 --- a/frameworks/cj/src/crypto_ffi.cpp +++ b/frameworks/cj/src/crypto_ffi.cpp @@ -431,7 +431,6 @@ namespace OHOS { authTag.data = static_cast(HcfMalloc(GCM_AUTH_TAG_LEN, 0)); if (authTag.data == nullptr) { HcfFree(gcmParamsSpec); - gcmParamsSpec = nullptr; return HCF_INVALID_PARAMS; } authTag.len = GCM_AUTH_TAG_LEN; @@ -476,7 +475,6 @@ namespace OHOS { authTag.data = static_cast(HcfMalloc(CCM_AUTH_TAG_LEN, 0)); if (authTag.data == nullptr) { HcfFree(ccmParamsSpec); - ccmParamsSpec = nullptr; return HCF_INVALID_PARAMS; } authTag.len = CCM_AUTH_TAG_LEN; diff --git a/frameworks/cj/src/mac_impl.cpp b/frameworks/cj/src/mac_impl.cpp index d9079c2..eb27e3a 100644 --- a/frameworks/cj/src/mac_impl.cpp +++ b/frameworks/cj/src/mac_impl.cpp @@ -25,7 +25,6 @@ namespace OHOS { MacImpl::~MacImpl() { HcfObjDestroy(this->macObj_); - this->macObj_ = nullptr; } HcfResult MacImpl::MacInit(HcfSymKey *symKey) diff --git a/frameworks/cj/src/md_impl.cpp b/frameworks/cj/src/md_impl.cpp index 747dae7..543a3b0 100644 --- a/frameworks/cj/src/md_impl.cpp +++ b/frameworks/cj/src/md_impl.cpp @@ -34,7 +34,6 @@ namespace OHOS { MdImpl::~MdImpl() { HcfObjDestroy(this->mdObj_); - this->mdObj_ = nullptr; } HcfResult MdImpl::MdDoFinal(HcfBlob *output) diff --git a/frameworks/cj/src/random_impl.cpp b/frameworks/cj/src/random_impl.cpp index b4e2155..c97b2ab 100644 --- a/frameworks/cj/src/random_impl.cpp +++ b/frameworks/cj/src/random_impl.cpp @@ -24,7 +24,6 @@ namespace OHOS { RandomImpl::~RandomImpl() { HcfObjDestroy(this->randObj_); - this->randObj_ = nullptr; } const char* RandomImpl::GetAlgName(int32_t* errCode) diff --git a/frameworks/cj/src/sign_impl.cpp b/frameworks/cj/src/sign_impl.cpp index 6db3450..719e168 100644 --- a/frameworks/cj/src/sign_impl.cpp +++ b/frameworks/cj/src/sign_impl.cpp @@ -25,7 +25,6 @@ SignImpl::SignImpl(HcfSign *signObj) SignImpl::~SignImpl() { HcfObjDestroy(this->signObj_); - this->signObj_ = nullptr; } HcfResult SignImpl::Init(HcfPriKey *priKey) diff --git a/frameworks/cj/src/sym_key_generator_impl.cpp b/frameworks/cj/src/sym_key_generator_impl.cpp index a604081..9d13539 100644 --- a/frameworks/cj/src/sym_key_generator_impl.cpp +++ b/frameworks/cj/src/sym_key_generator_impl.cpp @@ -24,7 +24,6 @@ namespace OHOS { SymKeyGeneratorImpl::~SymKeyGeneratorImpl() { HcfObjDestroy(this->generator_); - this->generator_ = nullptr; } const char *SymKeyGeneratorImpl::GetAlgName(int32_t* errCode) diff --git a/frameworks/cj/src/verify_impl.cpp b/frameworks/cj/src/verify_impl.cpp index ccdd362..1c9c0db 100644 --- a/frameworks/cj/src/verify_impl.cpp +++ b/frameworks/cj/src/verify_impl.cpp @@ -25,7 +25,6 @@ VerifyImpl::VerifyImpl(HcfVerify *verify) VerifyImpl::~VerifyImpl() { HcfObjDestroy(this->verify_); - this->verify_ = nullptr; } HcfResult VerifyImpl::Init(HcfPubKey *pubKey) diff --git a/frameworks/js/napi/crypto/src/napi_pri_key.cpp b/frameworks/js/napi/crypto/src/napi_pri_key.cpp index 6c460b1..ec077ca 100644 --- a/frameworks/js/napi/crypto/src/napi_pri_key.cpp +++ b/frameworks/js/napi/crypto/src/napi_pri_key.cpp @@ -164,7 +164,6 @@ napi_value NapiPriKey::JsGetEncodedPem(napi_env env, napi_callback_info info) HcfParamsSpec *paramsSpec = nullptr; NapiPriKey *napiPriKey = nullptr; if (!ValidateAndGetParams(env, info, format, ¶msSpec, &napiPriKey)) { - paramsSpec = nullptr; return NapiGetNull(env); } diff --git a/frameworks/native/src/asym_key.c b/frameworks/native/src/asym_key.c index 7efd880..55494d5 100644 --- a/frameworks/native/src/asym_key.c +++ b/frameworks/native/src/asym_key.c @@ -434,12 +434,10 @@ OH_Crypto_ErrCode OH_CryptoPrivKeyEncodingParams_SetParam(OH_CryptoPrivKeyEncodi switch (type) { case CRYPTO_PRIVATE_KEY_ENCODING_PASSWORD_STR: HcfFree(ctx->password); - ctx->password = NULL; ctx->password = data; break; case CRYPTO_PRIVATE_KEY_ENCODING_SYMMETRIC_CIPHER_STR: HcfFree(ctx->cipher); - ctx->cipher = NULL; ctx->cipher = data; break; default: diff --git a/frameworks/native/src/crypto_asym_cipher.c b/frameworks/native/src/crypto_asym_cipher.c index 5c9e537..9bc140e 100644 --- a/frameworks/native/src/crypto_asym_cipher.c +++ b/frameworks/native/src/crypto_asym_cipher.c @@ -178,25 +178,21 @@ OH_Crypto_ErrCode OH_CryptoSm2CiphertextSpec_SetItem(OH_CryptoSm2CiphertextSpec switch (item) { case CRYPTO_SM2_CIPHERTEXT_C1_X: HcfFree(spec->xCoordinate.data); - spec->xCoordinate.data = NULL; spec->xCoordinate.data = data; spec->xCoordinate.len = in->len; break; case CRYPTO_SM2_CIPHERTEXT_C1_Y: HcfFree(spec->yCoordinate.data); - spec->yCoordinate.data = NULL; spec->yCoordinate.data = data; spec->yCoordinate.len = in->len; break; case CRYPTO_SM2_CIPHERTEXT_C2: HcfFree(spec->cipherTextData.data); - spec->cipherTextData.data = NULL; spec->cipherTextData.data = data; spec->cipherTextData.len = in->len; break; case CRYPTO_SM2_CIPHERTEXT_C3: HcfFree(spec->hashData.data); - spec->hashData.data = NULL; spec->hashData.data = data; spec->hashData.len = in->len; break; diff --git a/plugin/mbedtls_plugin/rand/src/mbedtls_rand.c b/plugin/mbedtls_plugin/rand/src/mbedtls_rand.c index ccc959d..0ab9714 100644 --- a/plugin/mbedtls_plugin/rand/src/mbedtls_rand.c +++ b/plugin/mbedtls_plugin/rand/src/mbedtls_rand.c @@ -140,7 +140,7 @@ static void DestroyMbedtlsRand(HcfObjectBase *self) if (ctrDrbg != NULL) { mbedtls_ctr_drbg_free(ctrDrbg); HcfFree(ctrDrbg); - ctxDrbg = NULL; + ctrDrbg = NULL; } mbedtls_entropy_context *entropy = MbedtlsGetMdEntropy((HcfRandSpi *)self); if (entropy != NULL) { -- Gitee