diff options
author | Bastien Montagne <bastien@blender.org> | 2021-06-24 11:53:45 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-06-24 13:10:06 +0300 |
commit | 8cdb99d51c02d5cc60c774c176a43519c046e14c (patch) | |
tree | 0185df926bf3c14905d51a648c1d155cccc4dce1 /source/blender/blenloader | |
parent | 3a8347f82348ef2f430cdaa8a2e840ad3dba5a71 (diff) |
Fix linking code after own recent commit.
More stupid mistake in recent enhanced reports for file load code,
rB82c17082ba0e left some read-after-free situations.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/BLO_readfile.h | 5 | ||||
-rw-r--r-- | source/blender/blenloader/intern/blend_validate.c | 4 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readblenentry.c | 13 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile_tempload.c | 5 |
4 files changed, 17 insertions, 10 deletions
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index c2ac2df1f84..52ef577fceb 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -155,7 +155,9 @@ struct BLODataBlockInfo { }; BlendHandle *BLO_blendhandle_from_file(const char *filepath, struct BlendFileReadReport *reports); -BlendHandle *BLO_blendhandle_from_memory(const void *mem, int memsize); +BlendHandle *BLO_blendhandle_from_memory(const void *mem, + int memsize, + struct BlendFileReadReport *reports); struct LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype, @@ -260,6 +262,7 @@ typedef struct TempLibraryContext { /** Temporary main used to load data into (currently initialized from `real_main`). */ struct Main *bmain_base; struct BlendHandle *blendhandle; + struct BlendFileReadReport bf_reports; struct LibraryLink_Params liblink_params; struct Library *lib; diff --git a/source/blender/blenloader/intern/blend_validate.c b/source/blender/blenloader/intern/blend_validate.c index 0f729304128..5b093223fda 100644 --- a/source/blender/blenloader/intern/blend_validate.c +++ b/source/blender/blenloader/intern/blend_validate.c @@ -83,8 +83,8 @@ bool BLO_main_validate_libraries(Main *bmain, ReportList *reports) } BKE_library_filepath_set(bmain, curlib, curlib->filepath); - BlendHandle *bh = BLO_blendhandle_from_file(curlib->filepath_abs, - &(BlendFileReadReport){.reports = reports}); + BlendFileReadReport bf_reports = {.reports = reports}; + BlendHandle *bh = BLO_blendhandle_from_file(curlib->filepath_abs, &bf_reports); if (bh == NULL) { BKE_reportf(reports, diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index 1a324d56f06..44a26b9bf85 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -84,12 +84,13 @@ BlendHandle *BLO_blendhandle_from_file(const char *filepath, BlendFileReadReport * \param memsize: The size of the data. * \return A handle on success, or NULL on failure. */ -BlendHandle *BLO_blendhandle_from_memory(const void *mem, int memsize) +BlendHandle *BLO_blendhandle_from_memory(const void *mem, + int memsize, + BlendFileReadReport *reports) { BlendHandle *bh; - bh = (BlendHandle *)blo_filedata_from_memory( - mem, memsize, &(BlendFileReadReport){.reports = NULL}); + bh = (BlendHandle *)blo_filedata_from_memory(mem, memsize, reports); return bh; } @@ -398,8 +399,9 @@ BlendFileData *BLO_read_from_memory(const void *mem, { BlendFileData *bfd = NULL; FileData *fd; + BlendFileReadReport bf_reports = {.reports = reports}; - fd = blo_filedata_from_memory(mem, memsize, &(BlendFileReadReport){.reports = reports}); + fd = blo_filedata_from_memory(mem, memsize, &bf_reports); if (fd) { fd->skip_flags = skip_flags; bfd = blo_read_file_internal(fd, ""); @@ -426,8 +428,9 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain, BlendFileData *bfd = NULL; FileData *fd; ListBase old_mainlist; + BlendFileReadReport bf_reports = {.reports = reports}; - fd = blo_filedata_from_memfile(memfile, params, &(BlendFileReadReport){.reports = reports}); + fd = blo_filedata_from_memfile(memfile, params, &bf_reports); if (fd) { fd->skip_flags = params->skip_flags; BLI_strncpy(fd->relabase, filename, sizeof(fd->relabase)); diff --git a/source/blender/blenloader/intern/readfile_tempload.c b/source/blender/blenloader/intern/readfile_tempload.c index f440a06acf8..1b1cbb29ef5 100644 --- a/source/blender/blenloader/intern/readfile_tempload.c +++ b/source/blender/blenloader/intern/readfile_tempload.c @@ -36,12 +36,13 @@ TempLibraryContext *BLO_library_temp_load_id(struct Main *real_main, { TempLibraryContext *temp_lib_ctx = MEM_callocN(sizeof(*temp_lib_ctx), __func__); temp_lib_ctx->bmain_base = BKE_main_new(); + temp_lib_ctx->bf_reports.reports = reports; /* Copy the file path so any path remapping is performed properly. */ STRNCPY(temp_lib_ctx->bmain_base->name, real_main->name); - temp_lib_ctx->blendhandle = BLO_blendhandle_from_file( - blend_file_path, &(BlendFileReadReport){.reports = reports}); + temp_lib_ctx->blendhandle = BLO_blendhandle_from_file(blend_file_path, + &temp_lib_ctx->bf_reports); BLO_library_link_params_init( &temp_lib_ctx->liblink_params, temp_lib_ctx->bmain_base, 0, LIB_TAG_TEMP_MAIN); |