Fix memory issue about the value read by GDBM 54/147154/3 accepted/tizen/unified/20170905.184201 submit/tizen/20170904.073650
authorKichan Kwon <k_c.kwon@samsung.com>
Fri, 1 Sep 2017 07:20:32 +0000 (16:20 +0900)
committerKichan Kwon <k_c.kwon@samsung.com>
Mon, 4 Sep 2017 07:34:04 +0000 (16:34 +0900)
- Limit duplicated size
- Free after using

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

index a4490636c665ff4a1f374b2d4ec7027ab6baaceb..80cdc8d0444809bcfef63b996e7b2a6e0d356d61 100644 (file)
@@ -241,7 +241,9 @@ static int system_info_get_type(enum tag_type tag, const char *key,
                        *type = info_type[i].type_e;
                        ret = SYSTEM_INFO_ERROR_NONE;
 
-                       g_hash_table_insert(hashtable, strdup(key_internal), strdup(d_data.dptr));
+                       g_hash_table_insert(hashtable, strndup(key_internal, d_key.dsize),
+                                       strndup(d_data.dptr, d_data.dsize));
+                       free(d_data.dptr);
                        goto out;
                }
        }