dl dlopen: fix use-after-free
Re-structure the loop looking for duplicates a little so that we only have a single free of the string that happens regardless of whether we found a duplicate or not. This was Coverity CID 1288090
Этот коммит содержится в:
родитель
3efb5f56ae
Коммит
8fef4e865f
@ -210,16 +210,18 @@ static int dlopen_foreachfile(const char *search_path,
|
||||
|
||||
/* Have we already found this file? Or already found a
|
||||
file with the same basename (but different suffix)? */
|
||||
if (NULL != good_files) {
|
||||
for (int j = 0; NULL != good_files[j]; ++j) {
|
||||
if (strcmp(good_files[j], abs_name) == 0) {
|
||||
free(abs_name);
|
||||
continue;
|
||||
}
|
||||
bool found = false;
|
||||
for (int j = 0; NULL != good_files &&
|
||||
NULL != good_files[j]; ++j) {
|
||||
if (strcmp(good_files[j], abs_name) == 0) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
opal_argv_append_nosize(&good_files, abs_name);
|
||||
if (!found) {
|
||||
opal_argv_append_nosize(&good_files, abs_name);
|
||||
}
|
||||
free(abs_name);
|
||||
}
|
||||
closedir(dp);
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user