Fix memory leak 56/167156/2
authorSeungha Son <seungha.son@samsung.com>
Tue, 16 Jan 2018 01:32:09 +0000 (10:32 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Wed, 17 Jan 2018 05:25:04 +0000 (05:25 +0000)
Signed-off-by: Seungha Son <seungha.son@samsung.com>
Change-Id: Ie70c36a8d56acb5b13b9ae7812a4c58f2d42a035

src/pkgmgrinfo_certinfo.c

index ba072d6..f867c61 100644 (file)
@@ -464,6 +464,8 @@ API int pkgmgrinfo_set_cert_value(pkgmgrinfo_instcertinfo_h handle, pkgmgrinfo_i
        retvm_if(cert_type > PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
        pkgmgr_instcertinfo_x *certinfo = NULL;
        certinfo = (pkgmgr_instcertinfo_x *)handle;
+       if (certinfo->cert_info[cert_type])
+               free(certinfo->cert_info[cert_type]);
        (certinfo->cert_info)[cert_type] = strdup(cert_value);
        return PMINFO_R_OK;
 }