Fix reading past bounds removing from color ramp
[blender.git] / source / blender / blenkernel / intern / texture.c
index 60990c03b0efcdff52909341923847c783d537e1..ba04dd9b8f49e5e875a43743e425755064fa67c9 100644 (file)
@@ -549,11 +549,11 @@ int colorband_element_remove(struct ColorBand *coba, int index)
        if (index < 0 || index >= coba->tot)
                return 0;
 
+       coba->tot--;
        for (a = index; a < coba->tot; a++) {
                coba->data[a] = coba->data[a + 1];
        }
        if (coba->cur) coba->cur--;
-       coba->tot--;
        return 1;
 }