Preintialize the returned handle values to NULL 10/30310/1 accepted/tizen/common/20141114.192416 accepted/tizen/ivi/20141119.063313 submit/tizen_common/20141114.110816 submit/tizen_ivi/20141119.000000 submit/tizen_ivi/20141119.111111 submit/tizen_mobile/20141120.000000
authorBaptiste DURAND <baptiste.durand@open.eurogiciel.org>
Fri, 14 Nov 2014 10:55:36 +0000 (11:55 +0100)
committerBaptiste DURAND <baptiste.durand@open.eurogiciel.org>
Fri, 14 Nov 2014 10:59:49 +0000 (11:59 +0100)
For the following CAPI functions :
pkgmgrinfo_pkginfo_get_usr_pkginfo
pkgmgrinfo_appinfo_get_usr_appinfo
pkgmgrinfo_pkginfo_create_certinfo
pkgmgrinfo_create_certinfo_set_handle
pkgmgrinfo_create_pkgusrdbinfo
pkgmgrinfo_create_pkgdbinfo

this permit to not have a randoming value as handle and avoid crash
BUG-Tizen=TC-1744

Change-Id: Ib648328a6a964db200e7035b37b9d9fd6620caf1
Signed-off-by: Baptiste DURAND <baptiste.durand@open.eurogiciel.org>
src/pkgmgr-info.c

index 656c415..3cedef8 100755 (executable)
@@ -2904,6 +2904,7 @@ API int pkgmgrinfo_pkginfo_get_usr_pkginfo(const char *pkgid, uid_t uid, pkgmgri
        privilege_x *tmp5 = NULL;
        sqlite3 *pkginfo_db = NULL;
 
+       *handle = NULL;
        /*validate pkgid*/
        ret = db_util_open_with_options(getUserPkgParserDBPathUID(uid), &pkginfo_db, SQLITE_OPEN_READONLY, NULL);
        retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPathUID(uid));
@@ -5199,6 +5200,7 @@ API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid, pkgmgri
        char query[MAX_QUERY_LEN] = {'\0'};
        sqlite3 *appinfo_db = NULL;
 
+       *handle = NULL;
        /*open db*/
        _LOGD("getUserPkgParserDBPathUID(%d) returns: [%s]", uid, getUserPkgParserDBPathUID(uid));
        ret = db_util_open_with_options(getUserPkgParserDBPathUID(uid), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
@@ -7084,6 +7086,7 @@ API int pkgmgrinfo_pkginfo_create_certinfo(pkgmgrinfo_certinfo_h *handle)
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
        pkgmgr_certinfo_x *certinfo = NULL;
        certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
+       *handle = NULL;
        retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
        *handle = (void *)certinfo;
        return PMINFO_R_OK;
@@ -7192,6 +7195,7 @@ API int pkgmgrinfo_create_certinfo_set_handle(pkgmgrinfo_instcertinfo_h *handle)
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
        pkgmgr_instcertinfo_x *certinfo = NULL;
+       *handle = NULL;
        certinfo = calloc(1, sizeof(pkgmgr_instcertinfo_x));
        retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
        *handle = (void *)certinfo;
@@ -7483,7 +7487,7 @@ API int pkgmgrinfo_create_pkgusrdbinfo(const char *pkgid, uid_t uid, pkgmgrinfo_
 
        char *manifest = NULL;
        manifest_x *mfx = NULL;
-
+       *handle = NULL;
        manifest = pkgmgr_parser_get_usr_manifest_file(pkgid, uid);
        retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
 
@@ -7506,7 +7510,7 @@ API int pkgmgrinfo_create_pkgdbinfo(const char *pkgid, pkgmgrinfo_pkgdbinfo_h *h
 
        char *manifest = NULL;
        manifest_x *mfx = NULL;
-
+       *handle = NULL;
        manifest = pkgmgr_parser_get_manifest_file(pkgid);
        retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);