Fix memory leak
[platform/core/appfw/pkgmgr-info.git] / 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;
 }