Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Hughes <khughes@pacific.edu>2008-03-20 07:59:59 +0300
committerKen Hughes <khughes@pacific.edu>2008-03-20 07:59:59 +0300
commit3c7308614a92a0d09a3f72d212e523c9667d5052 (patch)
treef8dba63e972d1ab92c1830a924e8d033495e610b /source/blender/blenloader
parent1a4bbf988cbc311d492357fff611541a1ea1a5d8 (diff)
Python API
---------- Bugfix #6543: Blender.Library.Load() could segfault if called more than once with a library of different endian type. In the process discovered an invalid memory reference in other another function calling library_append(). Thanks to Brecht for the pointers on tracking this old bug down.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/BLO_readfile.h2
-rw-r--r--source/blender/blenloader/intern/readfile.c39
2 files changed, 19 insertions, 22 deletions
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index 09edfe90d02..b54d42080b0 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -238,7 +238,7 @@ char *BLO_gethome(void);
int BLO_has_bfile_extension(char *str);
void BLO_library_append(struct SpaceFile *sfile, char *dir, int idcode);
void BLO_library_append_(BlendHandle **libfiledata, struct direntry* filelist, int totfile, char *dir, char* file, short flag, int idcode);
-void BLO_script_library_append(BlendHandle *bh, char *dir, char *name, int idcode, short flag, struct Scene *scene);
+void BLO_script_library_append(BlendHandle **bh, char *dir, char *name, int idcode, short flag, struct Scene *scene);
BlendFileData* blo_read_blendafterruntime(int file, int actualsize, BlendReadError *error_r);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 92fb7690a03..ee4cb66a6e0 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -8578,38 +8578,38 @@ static void append_id_part(FileData *fd, Main *mainvar, ID *id, ID **id_r)
/* common routine to append/link something from a library */
static Library* library_append( Scene *scene, char* file, char *dir, int idcode,
- int totsel, FileData *fd, struct direntry* filelist, int totfile, short flag)
+ int totsel, FileData **fd, struct direntry* filelist, int totfile, short flag)
{
Main *mainl;
Library *curlib;
/* make mains */
- blo_split_main(&fd->mainlist, G.main);
+ blo_split_main(&(*fd)->mainlist, G.main);
/* which one do we need? */
- mainl = blo_find_main(fd, &fd->mainlist, dir, G.sce);
+ mainl = blo_find_main(*fd, &(*fd)->mainlist, dir, G.sce);
- mainl->versionfile= fd->fileversion; /* needed for do_version */
+ mainl->versionfile= (*fd)->fileversion; /* needed for do_version */
curlib= mainl->curlib;
if(totsel==0) {
- append_named_part(fd, mainl, scene, file, idcode, flag);
+ append_named_part(*fd, mainl, scene, file, idcode, flag);
}
else {
int a;
for(a=0; a<totfile; a++) {
if(filelist[a].flags & ACTIVE) {
- append_named_part(fd, mainl, scene, filelist[a].relname, idcode, flag);
+ append_named_part(*fd, mainl, scene, filelist[a].relname, idcode, flag);
}
}
}
/* make main consistant */
- expand_main(fd, mainl);
+ expand_main(*fd, mainl);
/* do this when expand found other libs */
- read_libraries(fd, &fd->mainlist);
+ read_libraries(*fd, &(*fd)->mainlist);
if(flag & FILE_STRINGCODE) {
@@ -8620,10 +8620,10 @@ static Library* library_append( Scene *scene, char* file, char *dir, int idcode,
BLI_makestringcode(G.sce, mainl->curlib->name);
}
- blo_join_main(&fd->mainlist);
- G.main= fd->mainlist.first;
+ blo_join_main(&(*fd)->mainlist);
+ G.main= (*fd)->mainlist.first;
- lib_link_all(fd, G.main);
+ lib_link_all(*fd, G.main);
lib_verify_nodetree(G.main, 0);
fix_relpaths_library(G.sce, G.main); /* make all relative paths, relative to the open blend file */
@@ -8642,8 +8642,9 @@ static Library* library_append( Scene *scene, char* file, char *dir, int idcode,
/* 20041208: put back. It only linked direct, not indirect objects (ton) */
/* patch to prevent switch_endian happens twice */
- if(fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
- blo_freefiledata( fd );
+ if((*fd)->flags & FD_FLAGS_SWITCH_ENDIAN) {
+ blo_freefiledata( *fd );
+ *fd = NULL;
}
return curlib;
@@ -8654,11 +8655,11 @@ static Library* library_append( Scene *scene, char* file, char *dir, int idcode,
/* append to G.scene */
/* this should probably be moved into the Python code anyway */
-void BLO_script_library_append(BlendHandle *bh, char *dir, char *name,
+void BLO_script_library_append(BlendHandle **bh, char *dir, char *name,
int idcode, short flag, Scene *scene )
{
/* try to append the requested object */
- library_append( scene, name, dir, idcode, 0, (FileData *)bh, NULL, 0, flag );
+ library_append( scene, name, dir, idcode, 0, (FileData **)bh, NULL, 0, flag );
/* do we need to do this? */
DAG_scene_sort(G.scene);
@@ -8674,6 +8675,7 @@ void BLO_library_append(SpaceFile *sfile, char *dir, int idcode)
void BLO_library_append_(BlendHandle** libfiledata, struct direntry* filelist, int totfile, char *dir, char* file, short flag, int idcode)
{
FileData *fd= (FileData*) (*libfiledata);
+ int lastflags = fd->flags;
Library *curlib;
Base *centerbase;
Object *ob;
@@ -8706,12 +8708,7 @@ void BLO_library_append_(BlendHandle** libfiledata, struct direntry* filelist, i
if(flag & FILE_AUTOSELECT) scene_deselect_all(G.scene);
- curlib = library_append( G.scene, file, dir, idcode, totsel, fd, filelist, totfile,flag );
-
- /* patch to prevent switch_endian happens twice */
- if(fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
- (*libfiledata)= 0;
- }
+ curlib = library_append( G.scene, file, dir, idcode, totsel, (FileData**) libfiledata, filelist, totfile,flag );
/* when not linking (appending)... */
if((flag & FILE_LINK)==0) {