Fixing more errors coverity found.
authorKent Mein <mein@cs.umn.edu>
Wed, 15 Apr 2009 16:16:00 +0000 (16:16 +0000)
committerKent Mein <mein@cs.umn.edu>
Wed, 15 Apr 2009 16:16:00 +0000 (16:16 +0000)
Imagepaint make sure ibuf exists before we use it.  This is CID# 545
editmesh_tools.c make sure were not indexing array with -1 This is CID# 137
(also removed some trailing whitespace I found)

anim5.c totlen could be -1 so check its > -1  This is CID# 134

Kent

source/blender/imbuf/intern/anim5.c
source/blender/src/editmesh_tools.c
source/blender/src/imagepaint.c

index ab203fe80de9c17300582a84a0030808a5e5a1d2..b6f29b6a1457e813df68e48c99b7e0b58c92a391 100644 (file)
@@ -425,7 +425,7 @@ int startanim5(struct anim * anim) {
        /* de hele file wordt in het geheugen gemapped */
 
        totlen = BLI_filesize(file);
-       if (totlen && file>=0) {
+       if (totlen>0 && file>=0) {
                lseek(file, 0L, SEEK_SET);
                
                mem= MEM_mallocN(totlen, "mmap");
index 690b4481ec97991089128498d0223bc15883ffee..377cb42e2f592f35b907c67120875767f9c50781 100644 (file)
@@ -2520,11 +2520,13 @@ void esubdivideflag(int flag, float rad, int beauty, int numcuts, int seltype)
                                                                }
                                                        }
                                                }
-                                               sort[hold]->f &= ~SELECT;
-                                               sort[hold]->f2 |= EDGENEW;
-                                               length[hold] = -1;
-                                       }                                                       
-                               } 
+                                               if (hold > -1) {
+                                                       sort[hold]->f &= ~SELECT;
+                                                       sort[hold]->f2 |= EDGENEW;
+                                                       length[hold] = -1;
+                                               }
+                                       }
+                               }
                                
                                // Beauty Long Edges
                                else {
@@ -2541,13 +2543,15 @@ void esubdivideflag(int flag, float rad, int beauty, int numcuts, int seltype)
                                                                }
                                                        }
                                                }
-                                               sort[hold]->f &= ~SELECT;
-                                               sort[hold]->f2 |= EDGENEW;
-                                               length[hold] = -1;
-                                       }                                                       
-                               }   
+                                               if (hold > -1) {
+                                                       sort[hold]->f &= ~SELECT;
+                                                       sort[hold]->f2 |= EDGENEW;
+                                                       length[hold] = -1;
+                                               }
+                                       }
+                               }
                        }
-               }       
+               }
        }
 
        gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); 
index ede6679b9f589a670eb3a8cd75a845b5e616da22..4d6c0898bcef8cbd91e41e01ee1ed79d5ffe78fd 100644 (file)
@@ -708,8 +708,7 @@ static int project_paint_PickColor(const ProjPaintState *ps, float pt[2], float
        }
        
        ibuf = BKE_image_get_ibuf((Image *)tf->tpage, NULL); /* TODO - this may be slow, the only way around it is to have an ibuf index per face */
-       
-
+       if (!ibuf) return 0;
        
        if (interp) {
                float x, y;