aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf/SkPDFFormXObject.cpp
diff options
context:
space:
mode:
authorGravatar edisonn@google.com <edisonn@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-10-18 21:03:59 +0000
committerGravatar edisonn@google.com <edisonn@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-10-18 21:03:59 +0000
commitdb14f8bb35056ac80820b6f605c84cf0165eae26 (patch)
tree612af3c1317d2ddf8c5aa58bc0051fd987d5fc66 /src/pdf/SkPDFFormXObject.cpp
parent9c875d34ff13d82f581448ced0d9eb5b067368b9 (diff)
PDF: Fail fast if in the tree of resources a child references a parent. Ideally I want a crash when the tree of resources became corrupt, not later when we try to finalize the pdf.
Review URL: https://codereview.appspot.com/6740047 git-svn-id: http://skia.googlecode.com/svn/trunk@6006 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/pdf/SkPDFFormXObject.cpp')
-rw-r--r--src/pdf/SkPDFFormXObject.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/pdf/SkPDFFormXObject.cpp b/src/pdf/SkPDFFormXObject.cpp
index c1e2192ac7..e148056afe 100644
--- a/src/pdf/SkPDFFormXObject.cpp
+++ b/src/pdf/SkPDFFormXObject.cpp
@@ -22,6 +22,15 @@ SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) {
// resources).
device->getResources(&fResources, false);
+ // Fail fast if in the tree of resources a child references a parent.
+ // If there is an issue, getResources will end up consuming all memory.
+ // TODO: A better approach might be for all SkPDFObject to keep track
+ // of possible cycles.
+#ifdef SK_DEBUG
+ SkTDArray<SkPDFObject*> dummy_resourceList;
+ getResources(&dummy_resourceList);
+#endif
+
SkRefPtr<SkStream> content = device->content();
content->unref(); // SkRefPtr and content() both took a reference.
setData(content.get());