fix [#31079] Revision 45893 crashes when I try to open a certain file created in it.
authorCampbell Barton <ideasman42@gmail.com>
Tue, 24 Apr 2012 10:25:12 +0000 (10:25 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 24 Apr 2012 10:25:12 +0000 (10:25 +0000)
nasty bug going from 2.63 --> 2.62 --> 2.63, could have incorrect/corrupt data.
fix checks for this case and clears the customdata layer.

source/blender/blenloader/intern/readfile.c

index b3d586f..d2f6100 100644 (file)
@@ -3810,6 +3810,14 @@ static void direct_link_customdata(FileData *fd, CustomData *data, int count)
        int i = 0;
 
        data->layers= newdataadr(fd, data->layers);
+
+       /* annoying workaround for bug [#31079] loading legacy files with
+        * no polygons _but_ have stale customdata */
+       if (UNLIKELY(count == 0 && data->layers == NULL && data->totlayer != 0)) {
+               memset(data, 0, sizeof(*data));
+               return;
+       }
+
        data->external= newdataadr(fd, data->external);
 
        while (i < data->totlayer) {