Fix AMD crashs when we try to launch an app by using a wrong appid 45/24645/1 accepted/tizen/common/20140723.152158 submit/tizen/20140717.160010
authorBaptiste DURAND <baptiste.durand@open.eurogiciel.org>
Thu, 17 Jul 2014 13:53:19 +0000 (15:53 +0200)
committerBaptiste DURAND <baptiste.durand@open.eurogiciel.org>
Thu, 17 Jul 2014 13:53:19 +0000 (15:53 +0200)
-> Return an error in appinfo_find when we don't find the app information
-> NULL is the correct way to return an error

Change-Id: I243c6cd81099aff40b64a5f1afb0e0c816619713
Signed-off-by: Baptiste DURAND <baptiste.durand@open.eurogiciel.org>
am_daemon/amd_appinfo.c

index 7b25565..6109cc4 100755 (executable)
@@ -439,12 +439,16 @@ const struct appinfo *appinfo_find(uid_t caller_uid, const char *appid)
        ret = pkgmgrinfo_appinfo_get_appinfo( appid, &handle);
        if (ret != PMINFO_R_OK){
                ret = pkgmgrinfo_appinfo_get_appinfo_user(appid , caller_uid , &handle);
+               if (ret != PMINFO_R_OK){
+                 _E("appid is not found in DB %s", appid);
+                 return NULL;
+               }
        }
 
        res = calloc(1, sizeof(*res));
        if (!res) {
                _E("create appinfo: %s", strerror(errno));
-               return -1;
+               return NULL;
        }
 
        memset(res, 0, sizeof(struct appinfo));
@@ -453,7 +457,7 @@ const struct appinfo *appinfo_find(uid_t caller_uid, const char *appid)
        if (!res->val[_AI_FILE]) {
                _E("create appinfo: %s", strerror(errno));
                _free_appinfo(res);
-               return -1;
+                return NULL;
        }
 
        res->val[_AI_NAME] = strdup(appid); //TODO :