Prevent crash when purging the gradients cache.
Bug #5133876

Change-Id: I3d1fa4e29498044796d725337ac93e6a1e8f0bcb
diff --git a/libs/hwui/GradientCache.h b/libs/hwui/GradientCache.h
index 086921c..45c1005 100644
--- a/libs/hwui/GradientCache.h
+++ b/libs/hwui/GradientCache.h
@@ -58,8 +58,8 @@
     }
 
     ~GradientCacheEntry() {
-        delete[] colors;
-        delete[] positions;
+        if (colors) delete[] colors;
+        if (positions) delete[] positions;
     }
 
     bool operator<(const GradientCacheEntry& r) const {