diff options
author | Mateusz Moscicki <m.moscicki2@partner.samsung.com> | 2020-05-05 10:01:23 +0200 |
---|---|---|
committer | Mateusz Moscicki <m.moscicki2@partner.samsung.com> | 2020-05-05 10:49:54 +0200 |
commit | 54d6539acb7564445ad74a9d9c12117665e5a0de (patch) | |
tree | 5c73bd53a8c6a3c576b566e1808549e71a153ab5 | |
parent | 3d7768f421d9ad89f63185f83fd607ac44571640 (diff) | |
download | crash-worker-54d6539acb7564445ad74a9d9c12117665e5a0de.tar.gz crash-worker-54d6539acb7564445ad74a9d9c12117665e5a0de.tar.bz2 crash-worker-54d6539acb7564445ad74a9d9c12117665e5a0de.zip |
Returns unique file paths from the maps file
This prevents duplicate entries in the *.so_info file
Change-Id: I49c4d4949d4d0075b056891557fe027d82b017a0
-rw-r--r-- | src/crash-manager/so-info.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/crash-manager/so-info.c b/src/crash-manager/so-info.c index 5dc26ff..d2526d7 100644 --- a/src/crash-manager/so-info.c +++ b/src/crash-manager/so-info.c @@ -215,6 +215,19 @@ static char *get_exe_filename(char *line) return NULL; } +bool list_contains_string(GSList *list, const char *string, const size_t max_len) +{ + if (list == NULL || string == NULL) + return false; + + for (GSList *iterator = list; iterator; iterator = iterator->next) { + if (strncmp((char*)iterator->data, string, max_len) == 0) + return true; + } + + return false; +} + GSList *get_filepaths(char *map_path) { char *line = NULL; @@ -242,7 +255,10 @@ GSList *get_filepaths(char *map_path) snprintf(file_name, n+1, "%s", exe_filename); - file_list = g_slist_append(file_list, file_name); + if (!list_contains_string(file_list, file_name, PATH_MAX)) + file_list = g_slist_append(file_list, file_name); + else + free(file_name); } } |