some mismatched malloc/free usage with osd_* functions (nw)

This commit is contained in:
Oliver Stöneberg 2014-03-24 21:44:43 +00:00
parent 738a0b82ab
commit b52f668f13
5 changed files with 12 additions and 8 deletions

View File

@ -1419,6 +1419,9 @@ void ui_menu_control_device_image::test_create(bool &can_create, bool &need_conf
need_confirm = false;
break;
}
if (entry != NULL)
osd_free(entry);
}
void ui_menu_control_device_image::load_software_part()

View File

@ -547,7 +547,7 @@ static file_error zippath_resolve(const char *path, osd_dir_entry_type &entry_ty
{
/* get the entry type and free the stat entry */
current_entry_type = current_entry->type;
free(current_entry);
osd_free(current_entry);
current_entry = NULL;
}
else

View File

@ -145,7 +145,7 @@ osd_directory_entry *osd_stat(const char *path)
// create an osd_directory_entry; be sure to make sure that the caller can
// free all resources by just freeing the resulting osd_directory_entry
result = (osd_directory_entry *)malloc(sizeof(*result) + strlen(path) + 1);
result = (osd_directory_entry *)osd_malloc_array(sizeof(*result) + strlen(path) + 1);
strcpy((char *)(result + 1), path);
result->name = (char *)(result + 1);
result->type = ENTTYPE_NONE;
@ -171,7 +171,8 @@ file_error osd_get_full_path(char **dst, const char *path)
{
// derive the full path of the file in an allocated string
// for now just fake it since we don't presume any underlying file system
*dst = strdup(path);
*dst = (char*)osd_malloc_array(strlen(path) + 1);
strcpy(*dst, path);
return FILERR_NONE;
}

View File

@ -446,7 +446,7 @@ osd_directory_entry *osd_stat(const char *path)
// create an osd_directory_entry; be sure to make sure that the caller can
// free all resources by just freeing the resulting osd_directory_entry
result = (osd_directory_entry *) malloc(sizeof(*result) + strlen(path) + 1);
result = (osd_directory_entry *) osd_malloc_array(sizeof(*result) + strlen(path) + 1);
if (!result)
goto done;
strcpy(((char *) result) + sizeof(*result), path);

View File

@ -64,7 +64,7 @@ file_error osd_open(const char *path, UINT32 openflags, osd_file **file, UINT64
}
// allocate a file object, plus space for the converted filename
*file = (osd_file *)malloc(sizeof(**file) + sizeof(TCHAR) * _tcslen(t_path));
*file = (osd_file *)osd_malloc_array(sizeof(**file) + sizeof(TCHAR) * _tcslen(t_path));
if (*file == NULL)
{
filerr = FILERR_OUT_OF_MEMORY;
@ -152,7 +152,7 @@ error:
// cleanup
if (filerr != FILERR_NONE && *file != NULL)
{
free(*file);
osd_free(*file);
*file = NULL;
}
osd_free(t_path);
@ -286,7 +286,7 @@ file_error osd_close(osd_file *file)
case WINFILE_FILE:
// close the file handle and free the file structure
CloseHandle(file->handle);
free(file);
osd_free(file);
break;
case WINFILE_SOCKET:
return win_close_socket(file);
@ -490,7 +490,7 @@ osd_directory_entry *osd_stat(const char *path)
// create an osd_directory_entry; be sure to make sure that the caller can
// free all resources by just freeing the resulting osd_directory_entry
result = (osd_directory_entry *)malloc(sizeof(*result) + strlen(path) + 1);
result = (osd_directory_entry *)osd_malloc_array(sizeof(*result) + strlen(path) + 1);
if (!result)
goto done;
strcpy(((char *) result) + sizeof(*result), path);