diff --git a/common/src/hcf_parcel.c b/common/src/hcf_parcel.c index fa8b56e6666c4b6fd651460fc247f5ad82f4ecc0..739868c8dce8e9d2d9e66161185259cdd34a7f38 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 c34fbc3cb2b0a6b21aa473e7b3bd3ed2d559a271..2e6663991a8cf75559dfc5dbf3a9a7f82b13065a 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 e240b5325f3b3e67bde67fccfef4a278a3f64a39..44fc470be8e9c2a33145fb7e145286bb2af71b7a 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 fd803f23e510487ea89456386e9b9daa01fd6114..75e038f69f488f2ff4ed26fcb064338eb21b8d0c 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 d9079c284b5cb2326b03bf7c5e005f58c597d727..eb27e3aea052df4ce84d70d76ee2490132c77bd2 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 747dae76d4bb83e3eb32ffea7b2244763f58736b..543a3b07435e5b55b0a25db7ba812ca0274eb88f 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 b4e2155fec076e247e6075aa913f23be4d3a430b..c97b2ab4bdb220dae75e62d177747cc15b9b1554 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 6db3450e706fadd4e4cec0e9f48931b244b593d7..719e168f883347888253039e2b9920bb28a31697 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 a60408194fe11ec5883f4c37953cb92ac9e4ea80..9d13539480ec00c26aaa3b5f639ff474f9603d52 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 ccdd3622853662c30456428038427a6bc4ae63bd..1c9c0db290d3ba46c4a9b960454ec3fd1650d4a1 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 6c460b1b0f0d2ad8396d5b77be6c0c9d0d218565..ec077ca7b96e0ec94d7a9888e0a2453fdd182c1f 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 7efd8800a5adfc71ee61b8e4a0c1aab7171c687e..55494d5255a5caabed1d7d59653172798a3cdcd8 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 5c9e53744d80d35d109de7de3b89066bf6b76ce9..9bc140e6674426c42ee3ee5d2b9095bb3e06d596 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 ccc959de2a430caffeea145c0a8933e83da6a7b2..0ab9714b54667de03ace063f5eae912d0401bc16 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) {