1
1

mca/base: fix misc memory leaks

as reported by Coverity with CIDs 710628, 1196713 and 1269855
Этот коммит содержится в:
Gilles Gouaillardet 2015-03-03 13:40:29 +09:00
родитель 134c866aa9
Коммит 852dbafd51
2 изменённых файлов: 14 добавлений и 11 удалений

Просмотреть файл

@ -12,6 +12,8 @@
* All rights reserved.
* Copyright (c) 2008-2010 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -339,14 +341,13 @@ static void find_dyn_components(const char *path, const char *type_name,
done */
return;
}
if (NULL == path_to_use) {
/* out of memory */
return;
}
} else {
path_to_use = strdup(path);
}
if (NULL == path_to_use) {
/* out of memory */
return;
}
/* If we haven't done so already, iterate over all the files in
the directories in the path and make a master array of all the
@ -417,6 +418,7 @@ static void find_dyn_components(const char *path, const char *type_name,
found_files list */
file = OBJ_NEW(component_file_item_t);
if (NULL == file) {
free(path_to_use);
return;
}
strncpy(file->type, type_name, MCA_BASE_MAX_TYPE_NAME_LEN);

Просмотреть файл

@ -14,6 +14,8 @@
* Copyright (c) 2012-2014 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2014 Intel, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -1096,13 +1098,12 @@ static int fixup_files(char **file_list, char * path, bool rel_path_search) {
for (i = 0 ; i < count; ++i) {
/* Absolute paths preserved */
if ( opal_path_is_absolute(files[i]) ) {
if( NULL == opal_path_access(files[i], NULL, mode) ) {
if( NULL == (tmp_file = opal_path_access(files[i], NULL, mode)) ) {
opal_show_help("help-mca-var.txt", "missing-param-file",
true, getpid(), files[i], path);
exit_status = OPAL_ERROR;
goto cleanup;
}
else {
} else {
opal_argv_append(&argc, &argv, files[i]);
}
}
@ -1138,8 +1139,6 @@ static int fixup_files(char **file_list, char * path, bool rel_path_search) {
else {
if( NULL != (tmp_file = opal_path_find(files[i], search_path, mode, NULL)) ) {
opal_argv_append(&argc, &argv, tmp_file);
free(tmp_file);
tmp_file = NULL;
}
else {
opal_show_help("help-mca-var.txt", "missing-param-file",
@ -1148,8 +1147,11 @@ static int fixup_files(char **file_list, char * path, bool rel_path_search) {
goto cleanup;
}
}
free(tmp_file);
}
tmp_file = NULL;
free(*file_list);
*file_list = opal_argv_join(argv, OPAL_ENV_SEP);
@ -1168,7 +1170,6 @@ static int fixup_files(char **file_list, char * path, bool rel_path_search) {
}
if( NULL != tmp_file ) {
free(tmp_file);
tmp_file = NULL;
}
return exit_status;