Index: src/effects/SkLayerRasterizer.cpp |
diff --git a/src/effects/SkLayerRasterizer.cpp b/src/effects/SkLayerRasterizer.cpp |
index 7143a3b40e915839406efb9fa401cd59d7a50ae2..dfbf8b9b209b712a2c074187cce456f74f2cb8cc 100644 |
--- a/src/effects/SkLayerRasterizer.cpp |
+++ b/src/effects/SkLayerRasterizer.cpp |
@@ -214,12 +214,21 @@ void SkLayerRasterizer::Builder::addLayer(const SkPaint& paint, SkScalar dx, |
} |
SkLayerRasterizer* SkLayerRasterizer::Builder::detachRasterizer() { |
- SkLayerRasterizer* rasterizer = SkNEW_ARGS(SkLayerRasterizer, (fLayers)); |
+ SkLayerRasterizer* rasterizer; |
+ if (0 == fLayers->count()) { |
+ rasterizer = NULL; |
+ SkDELETE(fLayers); |
+ } else { |
+ rasterizer = SkNEW_ARGS(SkLayerRasterizer, (fLayers)); |
+ } |
fLayers = NULL; |
return rasterizer; |
} |
SkLayerRasterizer* SkLayerRasterizer::Builder::snapshotRasterizer() const { |
+ if (0 == fLayers->count()) { |
+ return NULL; |
+ } |
SkDeque* layers = SkNEW_ARGS(SkDeque, (sizeof(SkLayerRasterizer_Rec), fLayers->count())); |
SkDeque::F2BIter iter(*fLayers); |
const SkLayerRasterizer_Rec* recOrig; |