filelen is set to the return result of BLI_filesize
authorKent Mein <mein@cs.umn.edu>
Tue, 5 Jun 2007 15:43:20 +0000 (15:43 +0000)
committerKent Mein <mein@cs.umn.edu>
Tue, 5 Jun 2007 15:43:20 +0000 (15:43 +0000)
which can return -1.  So lets check for -1 before calling malloc
and doing more work.

Another coverity fix.

Kent

source/blender/blenkernel/intern/exotic.c

index 9d5e76e9ce70bf2990e46e3bb0151ad6a4e64c1c..fe52a3fc198b738c901f8c7df6eaf1d0caa452a3 100644 (file)
@@ -1246,7 +1246,12 @@ static void read_inventor(char *str, struct ListBase *listb)
                error("Can't read file\n");
                return;
        }
+
        filelen= BLI_filesize(file);
+       if(filelen < 1) {
+               close(file);
+               return;
+       }
        
        maindata= MEM_mallocN(filelen, "leesInventor");
        read(file, maindata, filelen);