fix for missing NULL pointer checks and incorrect array free
authorCampbell Barton <ideasman42@gmail.com>
Sun, 17 Mar 2013 10:15:06 +0000 (10:15 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 17 Mar 2013 10:15:06 +0000 (10:15 +0000)
source/blender/editors/sculpt_paint/paint_image_2d.c
source/blender/imbuf/intern/dds/FlipDXT.cpp
source/blender/makesrna/intern/rna_object_force.c

index 8db1b1817b54dcbb132d1a8bd8c52af38f995c58..ed1b25d1b4e6867973773a49b4481b8f932cedc7 100644 (file)
@@ -704,7 +704,7 @@ int paint_2d_stroke(void *ps, const int prev_mval[2], const int mval[2], int era
        ImagePaintState *s = ps;
        BrushPainter *painter = s->painter;
        ImBuf *ibuf = BKE_image_acquire_ibuf(s->image, s->sima ? &s->sima->iuser : NULL, NULL);
        ImagePaintState *s = ps;
        BrushPainter *painter = s->painter;
        ImBuf *ibuf = BKE_image_acquire_ibuf(s->image, s->sima ? &s->sima->iuser : NULL, NULL);
-       int     is_data = ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA;
+       const bool is_data = (ibuf && ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA);
 
        if (!ibuf)
                return 0;
 
        if (!ibuf)
                return 0;
@@ -739,7 +739,7 @@ int paint_2d_stroke(void *ps, const int prev_mval[2], const int mval[2], int era
        brush_painter_2d_require_imbuf(painter, ((ibuf->rect_float) ? 1 : 0), 0, 0);
 
        if (painter->cache.enabled)
        brush_painter_2d_require_imbuf(painter, ((ibuf->rect_float) ? 1 : 0), 0, 0);
 
        if (painter->cache.enabled)
-               brush_painter_2d_refresh_cache(painter, newuv, is_data == FALSE);
+               brush_painter_2d_refresh_cache(painter, newuv, is_data == false);
 
        if (paint_2d_op(s, painter->cache.ibuf, olduv, newuv)) {
                imapaint_image_update(s->sima, s->image, ibuf, false);
 
        if (paint_2d_op(s, painter->cache.ibuf, olduv, newuv)) {
                imapaint_image_update(s->sima, s->image, ibuf, false);
index 660643530ba8f46ccb89582668a9b47d79a52bef..4f63d17dc902599a335ec6bec382dcc78d2acb93 100644 (file)
@@ -241,7 +241,7 @@ int FlipDXTCImage(unsigned int width, unsigned int height, unsigned int levels,
                                memcpy(line2, temp_line, row_bytes);
                        }
 
                                memcpy(line2, temp_line, row_bytes);
                        }
 
-                       delete temp_line;
+                       delete[] temp_line;
                }
 
                // mip levels are contiguous.
                }
 
                // mip levels are contiguous.
index 5ebc3f25c22ad96b9019798dd2d4650fc174994e..ab8b54334feb312f8e941b1bf75c1834171177bb 100644 (file)
@@ -483,7 +483,7 @@ static void rna_FieldSettings_update(Main *UNUSED(bmain), Scene *UNUSED(scene),
                        part->pd->tex = NULL;
                }
 
                        part->pd->tex = NULL;
                }
 
-               if (part->pd2->forcefield != PFIELD_TEXTURE && part->pd2->tex) {
+               if (part->pd2 && part->pd2->forcefield != PFIELD_TEXTURE && part->pd2->tex) {
                        part->pd2->tex->id.us--;
                        part->pd2->tex = NULL;
                }
                        part->pd2->tex->id.us--;
                        part->pd2->tex = NULL;
                }