[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51152] branches/ge_components/source/ blender/blenloader/intern: Fixing problems with loading blend files containing components in versions Blender with a different bitness (i.g., loading a file save with 32bit Blender and reading it with 64bit Blender).
Mitchell Stokes
mogurijin at gmail.com
Sun Oct 7 23:48:18 CEST 2012
Revision: 51152
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51152
Author: moguri
Date: 2012-10-07 21:48:17 +0000 (Sun, 07 Oct 2012)
Log Message:
-----------
Fixing problems with loading blend files containing components in versions Blender with a different bitness (i.g., loading a file save with 32bit Blender and reading it with 64bit Blender). There is a small memory leak now that I will have to investigate. I think it has to deal with not properly dealing with a null terminated array.
Modified Paths:
--------------
branches/ge_components/source/blender/blenloader/intern/readfile.c
branches/ge_components/source/blender/blenloader/intern/writefile.c
Modified: branches/ge_components/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/ge_components/source/blender/blenloader/intern/readfile.c 2012-10-07 20:07:30 UTC (rev 51151)
+++ branches/ge_components/source/blender/blenloader/intern/readfile.c 2012-10-07 21:48:17 UTC (rev 51152)
@@ -4653,11 +4653,13 @@
cprop->poin = newdataadr(fd, cprop->poin);
if (cprop->type == CPROP_TYPE_SET && cprop->poin) {
int a=0;
- char **item_str = (char**)cprop->poin;
- do {
+ char **item_str;
+
+ test_pointer_array(fd, (void **)&cprop->poin);
+ item_str = (char**)cprop->poin;
+
+ for(; item_str[a]; ++a)
item_str[a] = newdataadr(fd, item_str[a]);
- a++;
- } while (item_str[a-1]);
}
cprop= cprop->next;
}
Modified: branches/ge_components/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/ge_components/source/blender/blenloader/intern/writefile.c 2012-10-07 20:07:30 UTC (rev 51151)
+++ branches/ge_components/source/blender/blenloader/intern/writefile.c 2012-10-07 21:48:17 UTC (rev 51152)
@@ -1206,16 +1206,23 @@
while (cprop) {
writestruct(wd, DATA, "ComponentProperty", 1, cprop);
- if (cprop->poin)
- writedata(wd, DATA, MEM_allocN_len(cprop->poin), cprop->poin);
-
if (cprop->type == CPROP_TYPE_SET && cprop->poin)
{
+ int len = 1;
item_str = (char**)cprop->poin;
+
for (i=0; item_str[i]; ++i)
+ ++len;
+
+ writedata(wd, DATA, sizeof(void*)*len, cprop->poin);
+
+ for (i=0; i<len; ++i)
writedata(wd, DATA, MEM_allocN_len(item_str[i]), item_str[i]);
}
+ else if (cprop->poin)
+ writedata(wd, DATA, MEM_allocN_len(cprop->poin), cprop->poin);
+
cprop = cprop->next;
}
}
More information about the Bf-blender-cvs
mailing list