Fix memory issues 29/152429/3 accepted/tizen/4.0/unified/20170927.045608 submit/tizen_4.0/20170926.084004
authorKichan Kwon <k_c.kwon@samsung.com>
Tue, 26 Sep 2017 06:39:23 +0000 (15:39 +0900)
committerKichan Kwon <k_c.kwon@samsung.com>
Tue, 26 Sep 2017 06:52:56 +0000 (15:52 +0900)
- Prevent accessing out of array
- Free before exit

Change-Id: Ifbe15353753438efb1b0f79951121d717cd57038
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
src/init_db/system_info_db_init.c
src/system_info.c

index 1647e34..06ae5f3 100644 (file)
@@ -379,7 +379,7 @@ static int system_info_update_db(int argc, char *argv[])
                                        break;
                                }
                        }
-                       if (!runtime[rt].xml_prop) {
+                       if (rt == LANG_MAX || !runtime[rt].xml_prop) {
                                printf("Invalid language (%s)\n", optarg);
                                return 0;
                        }
index a449063..acdb049 100644 (file)
@@ -467,7 +467,7 @@ API int system_info_get_platform_type(const char *key, system_info_type_e *type)
 API int system_info_get_custom_type(const char *key, system_info_type_e *type)
 {
        int ret;
-       char *val;
+       char *val = NULL;
        size_t len;
 
        ret = system_info_get_type(TAG_TYPE_CUSTOM, key, type);
@@ -492,9 +492,11 @@ API int system_info_get_custom_type(const char *key, system_info_type_e *type)
                *type = SYSTEM_INFO_STRING;
        else {
                _E("Invalid type (%s)", val);
+               free(val);
                return SYSTEM_INFO_ERROR_INVALID_PARAMETER;
        }
 
+       free(val);
        return SYSTEM_INFO_ERROR_NONE;
        //LCOV_EXCL_STOP
 }