Prevent infinite loop when trimming the path cache

Change-Id: I04b5fa498336068f997c68d8613b35a99f67adbe
diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp
index afdc2c9..fb687cd 100644
--- a/libs/hwui/PathCache.cpp
+++ b/libs/hwui/PathCache.cpp
@@ -55,6 +55,8 @@
         PathCache::drawPath(t->path, t->paint, *bitmap, left, top, offset, width, height);
         t->setResult(bitmap);
     } else {
+        texture->width = 0;
+        texture->height = 0;
         t->setResult(NULL);
     }
 }
@@ -136,8 +138,7 @@
                 addTexture(entry, bitmap, texture);
                 texture->clearTask();
             } else {
-                ALOGW("Path too large to be rendered into a texture (%dx%d)",
-                        texture->width, texture->height);
+                ALOGW("Path too large to be rendered into a texture");
                 texture->clearTask();
                 texture = NULL;
                 mCache.remove(entry);
diff --git a/libs/hwui/ShapeCache.h b/libs/hwui/ShapeCache.h
index 58fea08..92314b0 100644
--- a/libs/hwui/ShapeCache.h
+++ b/libs/hwui/ShapeCache.h
@@ -717,7 +717,9 @@
             ALOGD("Shape %s deleted, size = %d", mName, size);
         }
 
-        glDeleteTextures(1, &texture->id);
+        if (texture->id) {
+            glDeleteTextures(1, &texture->id);
+        }
         delete texture;
     }
 }